According to flex-basis MDN documentation the flex-basis property calculates the size of a flex item related to the content box, unless a different option is defined by the box-sizing CSS property. But I didn't get the desired result neither in current Chrome nor in IE11.
I have written 2 examples:
.horizontal-layout {
display: flex;
flex-direction: row;
}
header > span {
flex: 1 1 100%;
}
header > .button {
background-color: grey;
}
header > .app-name {
background-color: orange;
}
header#with-border-padding > span {
box-sizing: border-box; /* this is not useful at all */
}
header#with-border-padding > .button {
border: 1px solid black;
padding-left: 5px;
}
<header class="horizontal-layout">
<span class="button">A</span>
<span class="app-name">B</span>
<span class="button">C</span>
</header>
<header id="with-border-padding" class="horizontal-layout">
<span class="button">A</span>
<span class="app-name">B</span>
<span class="button">C</span>
</header>
jsfiddle
- First example is a
<header>with 3<span>tags each one having aflex: 1 1 100%(flex-basisis 100%). So everyspanis given a third part of theheader. - Second example is equal to first one, but in this case the second
spanhas some border and some padding. I thought thatflex-growwould make same result as first example but it didn't. Then I saw theflex-basisMDN documentation and understood that I had to setbox-sizing: border-box;to the flex items so that theflex-basiswas related to theborder-box. But it didn't either! Anyone knows why?
So thanks if someone can clarify about second example question.
In my code you can easily compare the sizes given to the <span> tags between both examples.
