1
當您設置柔性比率(例如flex:1)時,它們應用於內容框(即不考慮填充)。這導致一些意想不到的行爲,在這個例子中:Flex將寬度應用於內容框
http://codepen.io/anon/pen/doYBad?editors=100
#c
{
background: red; width: 300px; height: 40px;
display: flex; align-items: stretch; box-sizing: border-box;
}
#l {background: blue; flex:1; }
#r {background: orange; flex:2; }
#c > * {padding: 20px; box-sizing: border-box; display: block;}
的容器是300像素。比例是2 - 1(右 - 左)。所以左邊的框應該是100px,但這不是因爲有填充。
如何使flexbox將寬度應用於整個盒子而不僅僅是內容盒?
請注意,我不能使用寬度屬性。
爲什麼'box-sizing:border-box'影響這個計算? – thebjorn