2.2 KiB
2.2 KiB
Shape separator
Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.
HTML
<div class="shape-separator"></div>
CSS
.shape-separator {
position: relative;
height: 48px;
}
.shape-separator::after {
content: '';
background-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxLjQxNCI+PHBhdGggZD0iTTEyIDEybDEyIDEySDBsMTItMTJ6IiBmaWxsPSIjZmZmIi8+PC9zdmc+);
position: absolute;
width: 100%;
height: 24px;
bottom: 0;
}
Demo
Explanation
position: relativeon the element establishes a Cartesian positioning context for pseudo elements.::afterdefines 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: absolutetakes 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: 24pxis the same height as the shape.bottom: 0positions the pseudo element at the bottom of the parent.
Browser support
✅ No caveats.