Frontend Masters Blog · 5 min readCSS & layout
Confetti + Shapes + random(): A Fun Combination!
Learn how to create a CSS‑only confetti explosion using the new random() function, pseudo‑elements, and @property variables. The guide shows positioning elements around shapes, adding random colors and translations, and controlling partial explosions with custom CSS variables.
- Use @property to expose sibling-index() and sibling-count() for pseudo‑elements
- Combine offset-distance and random() to distribute and scramble confetti on any shape
- Animate custom variables (--p, --r) to create partial or full hover‑triggered explosions