Answers for "How to prevent anchor links from scrolling behind a sticky header with one line of CSS"

CSS
2

How to prevent anchor links from scrolling behind a sticky header with one line of CSS

// src/scss/navigation.scss

$sticky-breakpoint: 32em;

// 1. Approximate height of sticky navigation.
[id] {
  @media (min-height: $sticky-breakpoint) {
    scroll-margin-top: 100px; // 1
  }
}

.navigation {
  // ...

  @media (min-height: $sticky-breakpoint) {
    position: sticky;
    top: 0;
  }
}
Posted by: Guest on June-12-2020

Code answers related to "How to prevent anchor links from scrolling behind a sticky header with one line of CSS"

Browse Popular Code Answers by Language