freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #33 of 50

scroll-snap · point · alignment

PrismaVSJank the Janitor
Prisma saysScroll snap makes a container lock to items as you scroll — carousels and slide decks.

Set scroll-snap-type: x mandatory on a scroll container and scroll-snap-align: center on its children, and scrolling snaps cleanly to each item. It powers carousels, full-page slide sections, and horizontal card rows — smooth native behavior with no JavaScript.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleBuild a horizontal snapping carousel of three full-width panels.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.car{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;gap:10px}.car>div{flex:0 0 80%;scroll-snap-align:center;height:120px;display:grid;place-items:center;color:#06040d;background:#b388ff}</style></head><body style="background:#06040d;padding:20px"><div class="car"><div>1</div><div>2</div><div>3</div></div></body></html>
▶ Open the interactive comic issue
‹ User-Select · Drag · Disabling Text SelectScroll-Behavior · Smooth Scrolling ›