1
I have a page that has a simple top menu that has some links that take the user straight to the section referring to this link:
<style>
nav {
width: 100%;
height: 60px;
position: fixed;
top: 0;
background-color: black;
}
section {
width: 100%;
height: 100vh;
}
#sec1 {
background-color: red;
}
#sec2 {
background-color: blue;
}
#sec3 {
background-color: green;
}
</style>
<nav>
<a href="#sec1">Link 1</a>
<a href="#sec2">Link 2</a>
<a href="#sec3">Link 3</a>
</nav>
<section id="sec1">
...
</section>
<section id="sec2">
...
</section>
<section id="sec3">
...
</section>
This navigation menu is set at the top, and because of this when I go straight to the section it covers part of the content, thus generating the need for the user to scroll the page to see this excerpt. My question is: is there any way to control this scrolling with CSS or Javascript? I thought about doing this by giving a padding-top in all the sections, but it doesn’t seem to be the right way.
I did not understand why the negative votes, I made a mistake in the question?
– Mateus Daniel
puts a
padding-top;
in thebody
, regulates according to what you like.padding-top: 70px
, for example.– Boi Programador