css - Flexbox item widths are affected by padding -
see http://jsfiddle.net/56qwuz6o/3/:
<div style="display:flex"> <div id="a">a</div> <div id="b">b</div> <div id="c">c</div> </div> div div { flex: 1 1 0; border:1px solid black; box-sizing: border-box; } #a { padding-right: 50px; }
when have padding set on flex item (#a
), width (in border-box
sense) affected. how make computed width ignore padding? ie. want each of boxes take 33% of document width.
edit: answers far. in reality, have more boxes in row have fixed width: ie. @ http://jsfiddle.net/56qwuz6o/7/, want #a
, #b
, #c
have same width.
<div style="display:flex; width: 400px"> <div id="a">a</div> <div id="b">b</div> <div id="c">c</div> <div id="d">d</div> </div> div div { flex: 1 1 33%; border:1px solid black; box-sizing: border-box; } #a { padding-right: 100px; } #d { flex-basis: 200px; width: 200px; }
1 option have set flex-basis: 33.33%
or number relative amount of children have. i'm not sure if there way dynamically.
Comments
Post a Comment