【发布时间】:2016-09-12 10:40:21
【问题描述】:
我有一个 flexbox 溢出的小问题:
html
<div class="first">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
css
* {
box-sizing: border-box;
}
body {
margin: 50px;
}
.first {
display: flex;
flex-flow: row nowrap;
}
.child {
background: red;
border: 1px blue solid;
height: 10px;
flex: 0 0 33.3%;
margin-right: 10px;
}
.first :last-child {
flex: 0 0 33.4%;
}
问题是最后一个孩子溢出了,为什么?我用 box-sizing 来代替边框?
【问题讨论】:
-
box-sizing对边距没有影响!你想做什么? -
好吧,如何在子项之间添加边距而不导致溢出