所以我一直在创建一个非常基本的网站,其中包含 header
、nav
、主容器和 footer
。并且我在我的网站中使用了 viewport
标签。
当我将 div
的 width
设置为 100%
时出现问题。
这是我的代码:
#header {
background-color: black;
color: white;
text-align: center;
padding: 5px;
}
#nav {
line-height: 60px;
background-color: #FFFFFF;
min-height: 60px;
width: 100%;
left: 0px;
text-decoration: none;
}
#nav a {
font-family: sans-serif;
font-size: 25px;
text-decoration: none;
float: left;
margin-left: 10px;
}
#section {
min-width: 50%;
min-height: 479px;
float: left;
}
#section p {
font-family: sans-serif;
font-size: 20px;
}
#footer {
background-color: black;
color: white;
clear: both;
text-align: right;
line-height: 40px;
height: 40px;
}
#footer p {
margin-right: 30px;
}
有什么我需要更改以摆脱 div 周围的白色边缘吗?我已经尝试过一些方法来摆脱它,但它们似乎都不起作用,我们将不胜感激。
最佳答案
body
跨浏览器有一个默认的margin
,所以你需要重置那个margin
。
所以加上这个
body {
margin: 0
}
关于html - 如何去除 div 标签周围的白边?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35543983/