CSSeasyCSS

CSS Scroll Snap Sections

Create smooth full-page scrolling with snap points for sections.

01

The problem

You want sections to snap into view when scrolling, creating a smooth full-page scroll experience.

02

The solution

CSS
.scroll-container {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

.scroll-section {
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Horizontal scroll snap */
.scroll-horizontal {
  display: flex;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  gap: 20px;
  padding: 20px;
}

.scroll-item {
  min-width: 300px;
  height: 400px;
  scroll-snap-align: center;
  border-radius: 12px;
  flex-shrink: 0;
}

/* Proximity snap (more relaxed) */
.scroll-proximity {
  scroll-snap-type: y proximity;
}

/* Hide scrollbar but keep functionality */
.scroll-container::-webkit-scrollbar {
  display: none;
}

.scroll-container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

03

See it live

Isolated previewSandboxed
04

Put it to work

Example
<!-- Vertical full-page scroll -->
<div class="scroll-container">
  <section class="scroll-section" style="background: #667eea;">
    <h1>Section 1</h1>
  </section>
  <section class="scroll-section" style="background: #764ba2;">
    <h1>Section 2</h1>
  </section>
  <section class="scroll-section" style="background: #f093fb;">
    <h1>Section 3</h1>
  </section>
</div>

<!-- Horizontal scroll gallery -->
<div class="scroll-horizontal">
  <div class="scroll-item" style="background: #3a7bff;"></div>
  <div class="scroll-item" style="background: #8b5cf6;"></div>
  <div class="scroll-item" style="background: #ec4899;"></div>
</div>

Worth knowing

scroll-snap-type: mandatory forces snapping. Use proximity for gentler snap behavior. Excellent for carousels and full-page sites.