Random Zig-Zag Dividers
Similar to the wavy divider, here is another cool shape powered by random(): A zig-zag divider!

.zig-zag {
--n: 9; /* if you change this, you need to add more points .. we don't have loops in CSS */
--d: 80px; /* control the depth, can be percentage */
--_r1: random(0px,var(--d)/2);
--_r2: random(var(--d)/2,var(--d));
clip-path: polygon(100% 0,0 0,
calc(000%/var(--n)) calc(100% - var(--_r2)),
calc(100%/var(--n)) calc(100% - var(--_r1)),
calc(200%/var(--n)) calc(100% - var(--_r2)),
calc(300%/var(--n)) calc(100% - var(--_r1)),
calc(400%/var(--n)) calc(100% - var(--_r2)),
calc(500%/var(--n)) calc(100% - var(--_r1)),
calc(600%/var(--n)) calc(100% - var(--_r2)),
calc(700%/var(--n)) calc(100% - var(--_r1)),
calc(800%/var(--n)) calc(100% - var(--_r2)),
calc(900%/var(--n)) calc(100% - var(--_r1))
)
}
See the Pen Random bottom Zig-Zag by Temani Afif (@t_afif) on CodePen.
We can adjust the code to have the zig-zag on the top:
.zig-zag {
--n: 9; /* if you change this, you need to add more points .. we don't have loops in CSS */
--d: 80px; /* control the depth, can be percentage */
--_r1: random(0px,var(--d)/2);
--_r2: random(var(--d)/2,var(--d));
clip-path: polygon(100% 100%,0 100%,
calc(000%/var(--n)) var(--_r2),
calc(100%/var(--n)) var(--_r1),
calc(200%/var(--n)) var(--_r2),
calc(300%/var(--n)) var(--_r1),
calc(400%/var(--n)) var(--_r2),
calc(500%/var(--n)) var(--_r1),
calc(600%/var(--n)) var(--_r2),
calc(700%/var(--n)) var(--_r1),
calc(800%/var(--n)) var(--_r2),
calc(900%/var(--n)) var(--_r1)
)
}
See the Pen Random top Zig-Zag by Temani Afif (@t_afif) on CodePen.
Or both top and bottom:
See the Pen Random zig-zag divider by Temani Afif (@t_afif) on CodePen.
Until better support, you can use my online generator to get a static version: css-generators.com/zig-zag-divider
More CSS Tips
- A Spring Connector Using Anchor Positioning and border-shape Another fancy connector using modern CSS features.
- A Foldable Zig-Zag Connector Using Modern CSS Another fancy demo powered by anchor positioning, scroll-driven animations, and border-shape.