📜  如何使用一行 CSS 代码示例防止锚链接滚动到粘性标题后面

📅  最后修改于: 2022-03-11 14:47:30.893000             🧑  作者: Mango

代码示例1
// 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;
  }
}