0
我拥有带Bootstrap响应式设计的网页。我已经从左侧和右侧添加了填充以包装,因此在移动设备中,边缘之间会存在一些空白。但是我的扩展菜单有一些背景色,必须采用完整的浏览器宽度。我怎样才能做到这一点?我可以用负边距来制作,但不会扩大背景颜色。有没有办法做到这一点,而不改变布局?展开父容器之外的子元素宽度
#wrapper {
box-sizing: border-box;
/* responsive, so it's real 'width: 100%' */
width: 150px;
height: 150px;
padding: 0 10px;
background-color: #ddd;
border: 1px solid green;
}
#wrapper .div {
background-color: #afa;
width: 100%;
height: 90px;
border: 1px solid red;
box-sizing: border-box;
margin-bottom: 10px;
}
#wrapper .div2 {
width: 100%;
height: 50px;
border: 1px solid red;
box-sizing: border-box;
background-color: #aaf;
}
<div id="wrapper">
<div class="div">Must expand till green borders</div>
<div class="div2">Must stay as is</div>
</div>