I have a navbar at the top of the page that I want to be fixed. The problem is that if I make it fixed as opposed to absolute or something, stuff that would normally be below it takes its place and it sits on top making the content invisible. Any way I can get them to notice the fixed element and position accordingly without having to position:absolute or position:relative all of them?
CodePudding user response:
nav{
width: 100%;
position: fixed;
top:0;
}
CodePudding user response:
Apply a margin-top
or padding-top
to the first non-fixed element on the page, with a value as high as the height of the fixed-position navbar. Typically that element would be main
, the first section
or similar, possibly also simply the first (non-fixed) div
, depending on your page structure.