Html 删除导航栏上方的空白区域
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24089363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove white space above nav bar
提问by kevin
How do I remove the white space above this navbar that I created?
如何删除我创建的导航栏上方的空白区域?
http://gyazo.com/b41271cad8d41c08c52ff26b1f1cab9e
http://gyazo.com/b41271cad8d41c08c52ff26b1f1cab9e
I have search StackOveflow for this answer, but can't find one that seems to fix my issue. I have set html, body padding/margin to 0 as well as reset all other elements. Does anyone have any advice?
我在 StackOveflow 上搜索了这个答案,但找不到似乎可以解决我的问题的答案。我已将 html、body padding/margin 设置为 0 并重置所有其他元素。有人有建议吗?
<nav id="header">
<div class="home-header">
<a href="#"><h1> testing this </h1></a>
</div>
</nav>
Here's the CSS
这是 CSS
#header {
position: relative;
margin: 0 auto 0;
padding-top: 0px;
background-color: $main-color;
}
回答by CMPS
回答by devadinesh
#header {
position: relative;
margin: 0;
padding-top: 0px;
background-color: $main-color;
}
body{
margin:0px;
}
<body>
<nav id="header">
<div class="home-header">
<a href="#"><h1> testing this </h1></a>
</div>
</nav>
</body>
Put The body
Tag margin:0px;
Header margin:0px;
Try This Code
把body
标签margin:0px;
头margin:0px;
试试这个代码