It is necessary to make a zigzag border of the block (from triangles).
How best to implement it?
.zig-zag { background: #1ba1e2; position: relative; } .zig-zag:after { background: linear-gradient(-45deg, transparent 20px, #1ba1e2 0), linear-gradient( 45deg, transparent 20px, #1ba1e2 0); background-position: left bottom; background-size: 20px 20px; content: ""; display: block; height: 20px; width: 100%; position: absolute; } /* Просто оформление, для зиг-зага не нужно */ body { margin: 0; } h1 { color: #fff; font-family: Arial; margin: 0; padding: 15px; text-align: center; } <div class="zig-zag"> <h1>Рамка зубцами</h1> </div> Translation of my answer to enSO :
Improved minimal CSS:
div { background: #1ba1e2; position: relative; } div:after { content: ""; display: block; position: absolute; width: 100%; height: 30px; background: linear-gradient(-45deg, transparent 75%, #1ba1e2 0) 0 50%, linear-gradient(45deg, transparent 75%, #1ba1e2 0) 0 50%; background-size: 30px 30px; } /* Стили чисто для демонстрации */ h1 { color: #fff; text-align: center; margin: 0; padding: 0.5em; } <div> <h1>Zig Zag Borders</h1> </div> If you want to remove duplicate values, you can also use CSS variables, also known as Custom properties . They work everywhere except IE.
:root { --background-color: #1ba1e2; --zigzag-item-size: 30px; } div { background: var(--background-color); position: relative; } div:after { content: ""; display: block; position: absolute; width: 100%; height: var(--zigzag-item-size); background: linear-gradient(-45deg, transparent 75%, var(--background-color) 0) 0 50%, linear-gradient(45deg, transparent 75%, var(--background-color) 0) 0 50%; background-size: var(--zigzag-item-size) var(--zigzag-item-size); } /* Стили чисто для демонстрации */ h1 { color: #fff; text-align: center; margin: 0; padding: 0.5em; } <div> <h1>Zig Zag Borders</h1> </div> I use 0 as the gradient steps so as not to duplicate the previous values, since according to the specification the gradient step cannot be less than the previous value.
In the case of a color-stop before it.
You can make a triangular border if that suits you. css3 shapes
#up-triangle { width: 0; height: 0; border-bottom: 120px solid green; border-left: 60px solid transparent; border-right: 60px solid transparent; } Source: https://ru.stackoverflow.com/questions/681442/
All Articles