Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.
<div class="shape-separator"></div>
.shape-separator {
position: relative;
height: 48px;
background: #333;
}
.shape-separator::after {
content: '';
background-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxLjQxNCI+PHBhdGggZD0iTTEyIDEybDEyIDEySDBsMTItMTJ6IiBmaWxsPSIjZmZmIi8+PC9zdmc+);
position: absolute;
width: 100%;
height: 24px;
bottom: 0;
}
position: relative
on the element establishes a Cartesian positioning context for pseudo elements.::after
defines a pseudo element.background-image: url(...)
adds the SVG shape (a 24x24 triangle in base64 format) as the background image of the pseudo element, which repeats by default. It must be the same color as the block that is being separated.position: absolute
takes the pseudo element out of the flow of the document and positions it in relation to the parent.width: 100%
ensures the element stretches the entire width of its parent.height: 24px
is the same height as the shape.bottom: 0
positions the pseudo element at the bottom of the parent.
✅ No caveats.