如图,我写的代码运行出来两边会有默认的8.5px外边距
我试过了body{margin:0px;}没有用
代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>index</title>
<link rel="stylesheet" type="text/css" href="css/base.css">
<link rel="stylesheet" type="text/css" href="css/common.css">
</head>
<body>
<div class="header w">头部</div>
<div class="box w">内容</div>
<div class="footer w">底部</div>
</body>
</html>
base.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
-webkit-font-smoothing: antialiased;
background-color: #fff;
font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
color: #666;
}
common.css
.w {
width: 1519px;
margin: 0 auto;
}
.header {
position: relative;
height: 105px;
background-color:red;
}
.footer {
position: relative;
height: 105px;
background-color:green;
}
我也尝试过在style标签里面写以上样式,但没有出现8.5px的外边距
这到底是什么原因呢?