flex: 1 是什么意思? [英] What does flex: 1 mean?
问题描述
众所周知,flex
属性是 flex-grow
、flex-shrink
和 的简写flex-basis
属性.它的默认值是0 1 auto
,表示
As we all know, the flex
property is a shorthand for the flex-grow
, flex-shrink
, and the flex-basis
properties. Its default value is 0 1 auto
, which means
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
但我注意到,在很多地方使用了 flex: 1
.它是 1 1 auto
还是 1 0 auto
的简写?我不明白这是什么意思,我在谷歌上什么也没得到.
but I've noticed, in many places flex: 1
is used. Is it shorthand for 1 1 auto
or 1 0 auto
? I can't understand what it means and I get nothing when I google.
推荐答案
解释如下:
https://www.w3.org/TR/css-flexbox-1/#flex-common
弹性:<正数>
等效于 flex:<正数>1 0. 使 flex 项目灵活并将 flex 基础设置为零,导致项目接收 flex 中指定比例的可用空间容器.如果 flex 容器中的所有项目都使用此模式,则它们的尺寸将与指定的弹性系数成正比.
flex: <positive-number>
Equivalent to flex: <positive-number> 1 0. Makes the flex item flexible and sets the flex basis to zero, resulting in an item that receives the specified proportion of the free space in the flex container. If all items in the flex container use this pattern, their sizes will be proportional to the specified flex factor.
因此 flex:1
等价于 flex: 1 1 0
这篇关于flex: 1 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!