Is there any benefit or reason to change display property of a flex box item?
Especially, I\'m interested in using display:block
and display:inlin
From the specifciation:
The display value of a flex item is blockified: if the specified display of an in-flow child of an element generating a flex container is an inline-level value, it computes to its block-level equivalent. (See CSS2.1§9.7 [CSS21] and CSS Display [CSS3-DISPLAY] for details on this type of display value conversion.)
So basically, setting inline-block
or block
will do nothing as both will get computed to block
but you can set table
or inline-table
and your flex item will behave as a table. Same thing if you set inline-grid
or grid
.box {
display: flex;
margin:5px;
}
.box>div {
height: 50px;
width: 100%;
background: red;
display: grid;
grid-template-columns: 200px 1fr;
grid-template-rows: 1fr;
grid-gap: 20px;
}
span {
border: 2px solid green;
}
<div class="box">
<div>
<span></span>
<span></span>
</div>
</div>
<div class="box">
<div style="display:inline-grid;">
<span></span>
<span></span>
</div>
</div>
For the second case you can see it computes to grid