Why does my header moves down when I set it fixed?

2556 views html
-1

In my header I put the title of the page and my navbar, but as soon as I set it position:fixed; the margin on the top increased. Here is the link to Codepen: https://codepen.io/akafadam/pen/WaXaOV.

#header{
    background-color:#191919;
    height:3rem;
    width:100%;
    position:fixed;
}

answered question

Try to add top:0;

1 Answer

10

Add in

#header{
   top:0;
...
}

posted this

Have an answer?

JD

Please login first before posting an answer.

Ads

Categories