CSS: How can I get rid of the default window “padding”? An element set to 100% width doesn't reach the window's borders

前端 未结 4 643
孤城傲影
孤城傲影 2021-02-03 22:35

So I have an element that is placed directly inside body:


    
Some stuff...
Other stuff...
4条回答
  •  长发绾君心
    2021-02-03 23:11

    I found this problem continued even when setting the BODY MARGIN to zero.

    However it turns out there is an easy fix. All you need to do is give your HEADER tag a 1px border, aswell as setting the BODY MARGIN to zero, as shown below.

    body { margin:0px; }
    
    header { border:1px black solid; }
    

    Not sure why this works, but I use Chrome browser. Obviously you can also change the colour of the border to match your header colour.

提交回复
热议问题