弹性项目的显示值是 blockified :如果生成弹性容器的元素的流入子项的指定显示为内联级别值 ,它会计算为等效的块级. (有关此类显示值转换的详细信息,请参见CSS2.1§9.7[CSS21]和CSS Display [CSS3-DISPLAY].)
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.)
因此,基本上,设置inline-block
或block
不会做任何事情,因为两者都会被计算为block
,但是您可以设置table
或inline-table
,并且flex项目将表现为表格.如果设置inline-grid
或grid
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>
对于第二种情况,您可以看到它计算为grid
For the second case you can see it computes to grid
这篇关于弹性框项目的显示属性的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!