I have the below html, where I set default flex properties are being used.
<div class="container">
<div class="box"> BOX 1</div>
<div class="box"> BOX 2</div>
<div class="box box2"> BOX 3 .</div>
</div>
and styles are:
.container {
border: 1px solid #59c;
width: 60vw;
background: #ccc;
height: 200px;
margin: 0 auto;
display: flex;
padding: 30px;
}
.box {
font-size: 18px;
font-weight: 800;
background: #e5f;
border: 1px solid #99c;
padding: 20px;
}
Now, in my chrome browser I do see box 1 and box 2 has computed width of 94.52px, and box3 has 103.52px. The fiddle b666tkj9. Now when I do add below style:
.box2 {
flex: 2 1;
}
and flex: 1 1;
to the .box {}
rules, the computed width becomes now
226.5px for Box 1 and 2, and Box 3 got 411px.
My parent container width is 864px. So, 864 - 103.53 + (94.52 * 2)
is equal to 571.43px. So this amount of space is distributed then, but I am not able to do the math which can show how each box got its final width.
Can anyone help by explaining this?