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