How do I prevent the position fixed navbar to cover the top content of my page?
So I declared 100vh height for each page to my one page website. When I add the position fixed navbar which has the height of 50px, it covers up the 50px top content of my page. My desired output is to have a 100vh height for each page with a fixed navbar on top.
I tried adding margin, padding, and top value but is messes up the other page.
As far as I remember, I used calc to solve this problem before but I already forgot how to
3
Answers
try this
If you want to calc the height of your page based on navbar height, there are two ways:
so you don’t need to make it fixed, just normal position like this
then
You don’t need fixed cuz u don’t want to cover top content and there is no need to keep it top (cuz 100vh means you won’t scroll your page)
Anyway, if you still claim that you need
position: fixed
you can addpadding-top: 50px
to your page, bearing in mind that you need to add this 50px to your height calc (thats not a good solution, as I said before, you probably don’t need position fixed)