Does anyone know how to create a triangle cut effect on a div without the background being rendered as a rectangle?
body {
background: #333;
}
.parent {
height: 200px;
background: yellow;
position: relative;
overflow: hidden;
display: block;
}
.parent:before {
content: '';
position: absolute;
bottom: 0;
width: 100%;
height: 20%;
background: linear-gradient(190deg, transparent 20%, #FFFFFF 20.2%), linear-gradient(90deg, #FFFFFF 0%, #FFFFFF 100%);
z-index: 2;
}
<div class="parent"></div>
I am aiming for a design like this:
https://i.sstatic.net/jJe8Q.png
The goal is not to 'cut' the .parent
div itself but to have the cut effect on another div that sits on top of it. The triangle cut will be white with transparency around it to reveal what's inside the .parent
div.
Based on the image provided, here is the breakdown:
- The yellow div represents
.parent
. - The white triangle corresponds to
.slant
.