Simply because the flex-grow
will make the element to consume the free space. In your case the first element has 100px
of width and the other one is having width equal to its content so the free space is (width of container - 100px - content of box2)
. This free space will be split equally and added to both element and it's logical that the first one will be bigger since initially it was already bigger.
In your example, the second element is about 29px
and if we fix the width of the container to 600px
for example, we will have a free space equal to 471px
so both elements will end with 335.5px
and 264.5px
of width.
.wrapper {
display: flex;
width:600px;
}
.box1 {
background: red;
width: 100px;
flex-grow: 1;
}
.box2 {
background: green;
flex-grow: 1;
}
<div class="wrapper">
<div class="box1">One</div>
<div class="box2">Two</div>
</div>