border-box

Why is padding expanding a flex item?

北战南征 提交于 2019-11-28 13:16:48
In the snippet below, the first row has two divs with flex-grow: 1 . As expected, each div takes up 50% of the screen. When adding padding to the left div, that is no longer the case. Can someone explain why? body > div { height: 50px; display: flex; } body > div > div { flex: 1; box-sizing: border-box; } #a { background-color: red; } #b { background-color: green; } #c { padding: 10px; background-color: blue; } #d { background-color: yellow; } <div> <div id="a"></div> <div id="b"></div> </div> <div> <div id="c"></div> <div id="d"></div> </div> The calculations are defined in the spec. A flex

Inconsistent box model between <input type=“submit”/> and <input type=“text” />

空扰寡人 提交于 2019-11-28 09:16:39
I realised that <input type="submit"/> has a border-box box model, whereas <input type="text"/> has a content-box box model. This behavior is present in IE8 and FF. Unfortunately, this prevents me from applying this style for nice evenly sized inputs: input, textarea { border: 5px solid #808080; padding:0px; background-color:#C0C0C0; width:20em; } Is this correct behaviour by IE and FF? And is there a cross-browser way around this problem? Is this correct behaviour by IE and FF? It's not really stated in the standard how form field decorations are controlled by CSS. Originally they were

Chrome vs. box-sizing:border-box in a display:table

邮差的信 提交于 2019-11-28 08:08:38
问题 I'm doing a small 2-pane layout using display:table . For spacing (also from the background image), I use padding . As I need the children to have an exact width:50% from the available space (taking regard for the padding of the parent div ), I use box-sizing:border-box . This works fine in Opera, but in Chrome the box-sizing:border-box or even -webkit-box-sizing:border-box is silently ignored. I made a demo which shows the issue. The two red boxes should be square and the blue box should be

How to get equal width of input and select fields

自古美人都是妖i 提交于 2019-11-27 10:11:13
On the form, I have one select and two input fields. These elements are vertically aligned. Unfortunately, I can't get equal width of these elements. Here's my code: <select name="name1" style="width:198px"> <option>value1</option> <option>value2</option> </select><br/> <input type="text" name="id1" style="width:193px"><br/> <input type="text" name="id2" style="width:193px"> For above example, the best width for select element is 198 or 199 px (of course I tried 193px, but the difference is major). I think, it depends on resolution, on various computers and browsers since these elements don't

Why is padding expanding a flex item?

六月ゝ 毕业季﹏ 提交于 2019-11-27 07:35:07
问题 In the snippet below, the first row has two divs with flex-grow: 1 . As expected, each div takes up 50% of the screen. When adding padding to the left div, that is no longer the case. Can someone explain why? body > div { height: 50px; display: flex; } body > div > div { flex: 1; box-sizing: border-box; } #a { background-color: red; } #b { background-color: green; } #c { padding: 10px; background-color: blue; } #d { background-color: yellow; } <div> <div id="a"></div> <div id="b"></div> </div

Inconsistent box model between <input type=“submit”/> and <input type=“text” />

落爺英雄遲暮 提交于 2019-11-27 05:50:34
问题 I realised that <input type="submit"/> has a border-box box model, whereas <input type="text"/> has a content-box box model. This behavior is present in IE8 and FF. Unfortunately, this prevents me from applying this style for nice evenly sized inputs: input, textarea { border: 5px solid #808080; padding:0px; background-color:#C0C0C0; width:20em; } Is this correct behaviour by IE and FF? And is there a cross-browser way around this problem? 回答1: Is this correct behaviour by IE and FF? It's not

How to get equal width of input and select fields

孤街醉人 提交于 2019-11-26 15:04:59
问题 On the form, I have one select and two input fields. These elements are vertically aligned. Unfortunately, I can't get equal width of these elements. Here's my code: <select name="name1" style="width:198px"> <option>value1</option> <option>value2</option> </select><br/> <input type="text" name="id1" style="width:193px"><br/> <input type="text" name="id2" style="width:193px"> For above example, the best width for select element is 198 or 199 px (of course I tried 193px, but the difference is