这可能很简单,但我有几个使用媒体查询进行大小调整的嵌套div。我最初将盒子3作为容器下面的单独的div,但是引发了问题。所以我包括在容器中,并在框2格以下。我想这个div盒3占据屏幕的整个宽度。如何让div占据整个屏幕的宽度?
这里是例如:https://jsfiddle.net/nsnhsLjq/
还赞赏上完全改善我的代码的任何反馈。谢谢。
.box1 {
width: 50%;
padding: 15px;
height: 150px;
background: url(https://static.pexels.com/photos/27714/pexels-photo-27714.jpg) no-repeat center center scroll;
background-position: 50% 50%;
background-size: 90%;
margin: 0 auto;
}
.box2 {
width: 80%;
padding: 15px;
background-color: blue;
color: #fff;
margin: 0 auto;
margin-top: 80px;
}
.box3 {
background-color: #ccc;
text-align: center;
}
<div class="container">
<div class="box1">
<div class="box2">
Box 2:
</div>
<div class="box3">
Box 3:
</div>
</div>
</div>
为什么'箱3'嵌套在'箱1'? – s0rfi949
如果我没有嵌套它,方框3会在方框1而不是2之间缠绕。 –