scroll-padding (ok)

https://codepen.io/EinLinuus/pen/gOgjBpO

<!doctype html>
<html>
<style type="text/css">
html {
  scroll-padding-top: 50px;
}
nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 50px;
  width: 100%;
  background-color: white;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}
html,
body {
  font-family: "Arial";
  padding: 0;
  margin: 0;
}
body {
  padding-top: 50px;
}
section {
  height: 100vh;
}
section:nth-child(1) {
  background-color: yellow;
}
section:nth-child(2) {
  background-color: orange;
}
section:nth-child(3) {
  background-color: lightgreen;
}
section:nth-child(4) {
  background-color: lightblue;
}
h1 {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 50px;
  margin: 0;
}
</style>
<body>
  <nav>
    <a href="#home">Home</a>
    <a href="#pricing">Pricing</a>
    <a href="#plans">Plans</a>
    <a href="#contact">Contact</a>
  </nav>
  <section id="home">
    <h1>Home</h1>
  </section>
  <section id="pricing">
    <h1>Pricing</h1>
  </section>
  <section id="plans">
    <h1>Plans</h1>
  </section>
  <section id="contact">
    <h1>Contact</h1>
  </section>
</body>
</html>

Last updated