So, I have this single page that consists of a few sections. Users can go to these sections by scrolling themselves or clicking in the navbar (a href with anchor). Due to the Bootstrap 4 navbar being fixed to the top, the content gets placed under it. Is there a way I could offset anchors by -54px, so that whenever I click on an anchor link, it would show the content below the navbar (X:54px) and not under the navbar (X:0px).
Made this codepen to show the problem I'm facing:
https://codepen.io/anon/pen/XEjaKv
Whenever you click an anchor link, it will take you to the section, however, the navbar is covering the text..
All sections are 100 viewheight.
SCSS used:
.container{
section{
height: 100vh;
&#section1{
margin-top: 54px; // we need to offset the first section by 54px because of the navbar..
}
&#section1, &#section3{
background-color: #ddd;
}
&#section2, &#section4{
background-color:#ccc;
}
}
}
html{
scroll-behavior:smooth;
}