scroll-padding-top

Sets the top padding of a scroll container to adjust scroll snap positions. The most effective way to fix content being hidden behind a sticky/fixed header.

Class List

Pattern: spt{value}{unit}

ClassCSSDescription
spt0scroll-padding-top: 0No scroll padding
spt8pxscroll-padding-top: 8px8px padding
spt16pxscroll-padding-top: 16px16px padding
spt2remscroll-padding-top: 2rem20px padding
spt4remscroll-padding-top: 4rem40px padding
spt6remscroll-padding-top: 6rem60px padding (typical header height)
spt8remscroll-padding-top: 8rem80px padding
spt10remscroll-padding-top: 10rem100px padding

Usage Examples

<!-- Top padding on scroll container -->
<html class="spt6rem">
  <!-- All anchor links (#id) positioned 60px below -->
</html>

<!-- Scroll snap + padding -->
<div class="spt4rem oya h100vh">
  <section id="s1">Section 1</section>
  <section id="s2">Section 2</section>
</div>

Key Pattern: Fixed Header Compensation

Fixes content being obscured by a fixed header when navigating via anchor links (#id).

<!-- Page with fixed header -->
<html class="spt8rem">
<body>
  <header class="pf t0 l0 w100p h6rem bg000000 zi100">
    <nav>
      <a href="#about">About</a>
      <a href="#contact">Contact</a>
    </nav>
  </header>

  <!-- Anchor navigation positions at 80px below header -->
  <section id="about">...</section>
  <section id="contact">...</section>
</body>
</html>

Tips & Notes

scroll-padding-top vs scroll-margin-top

spt only needs to be set once on the scroll container (usually html) to apply to all anchors. smt requires individual settings on each target element.

Match the Header Height

Set scroll-padding-top equal to or slightly larger than the fixed header height. For a 60px header, use spt6rem or spt8rem.