1
为什么.column2
具有100%的宽度不会“负出”本身,而负边距?带有负边距的填充内部元素的容器不能正常工作
为什么.column1
与auto
宽度'out-dent'本身具有负边距而不是.column2
?
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container {
height: 150px;
width: 450px;
background-color: cyan;
padding: 15px;
}
.column1 {
height: auto;
width: auto;
background-color: red;
margin-left: -15px;
margin-right: -15px;
}
.column2 {
height: auto;
width: 100%;
background-color: green;
margin-left: -15px;
margin-right: -15px;
}
<div class='container'>
<div class='column1'>hello</div>
<div class='column2'>hola</div>
</div>
@RobertRocha正在读一些老问题...给予好评,如果答案帮助你,谢谢! – kukkuz