我有下面的 HTML 代码和 CSS:
body{
background-color: #C7C7C7;
}
#content{
background-color: #FFF;
text-align: center;
}
.warp{
padding:15px;
display: inline-block;
width: 700px;
background-color: red;
}
#header{
width: 100%;
background-color: #000;
color: #FFF;
}
<body>
<div id="header">
HEADER IS HERE
</div>
<div id="content">
<div class="warp">
CONTENT IS HERE
</div>
</div>
</body>
但是当我调整浏览器大小时,标题 div 不是 width: 100%
您可以在这张图片中看到:
如何解决?
非常感谢。
最佳答案
嘿,你的标题没有问题。 问题出在你的
.warp{
padding:15px;
display: inline-block;
width: 700px;<-- because of fixed width content go outside the body tag
background-color: red;
}
关于html - 为什么宽度为 : 100% is not assuming the full window width size?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27854440/