我有这段代码,但奇怪的是最大宽度和属性不起作用:
HTML:
<body>
<img src="imgs/topBar.png">
<div id ="wrapper">
</div>
</body>
CSS:
body {
padding: 0;
margin: 0;
}
body img:first-child{
width: 100%;
height: 5px;
margin:0;
display: block;
}
#wrapper {
width: 100%;
max-width: 1200px;
height: 100px;
margin: 0 auto;
border: 4px solid;
}
答案 0 :(得分:7)
您可以设置:
#wrapper {
-webkit-box-sizing: border-box; /* Safari, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
width: 100%;
max-width: 1200px;
height: 100px;
margin: 0 auto;
border: 4px solid;
}