本文共 2481 字,大约阅读时间需要 8 分钟。
flexbox
The flex-basis
property defines the size of the flex-item
along the main axis of the flex container. The main axis is horizontal if flex-direction
is set to row
and it’ll be vertical if the flex-direction
property is set to column
.
flex-basis
属性定义沿flex容器的主轴的flex-item
的大小。 如果flex-direction
设置为row
,则主轴为水平轴;如果flex-direction
属性设置为column
,则主轴为垂直轴。
flex-basis: auto | content || ;
flex-basis: auto
looks up the main size of the element and defines the size. For example, on a horizontal flex container, auto
will look for width
and height
if the container axis is vertical.
flex-basis: auto
查找元素的主要尺寸并定义尺寸。 例如,在水平伸缩容器上,如果容器的轴是垂直的,则auto
将查找width
和height
。
If no size is specified, auto
will fall back to content
.
如果未指定大小,则auto
将退回到content
。
flex-basis: content
resolves the size based on the element’s content, unless width
or height
is set through normal box-sizing
.
flex-basis: content
除非元素的width
或height
是通过常规box-sizing
设置的,否则content会根据元素的flex-basis: content
解析box-sizing
。
In both the cases where flex-basis
is either auto
or content
, if main size is specified, that size will take priority.
在flex-basis
是auto
或content
两种情况下,如果指定了main size,则以该大小flex-basis
。
This is just as specifying width
or height
, but only more flexible. flex-basis: 20em;
will set the initial size of the element to 20em
. Its final size will be based on available space, flex-grow
multiple and flex-shrink
multiple.
就像指定width
或height
,但是更加灵活。 flex-basis: 20em;
将元素的初始大小设置为20em
。 其最终大小将取决于可用空间, flex-grow
倍数和flex-shrink
倍数。
The specification suggests use of flex
shorthand property. This helps write flex-basis
along with flex-grow
and flex-shrink
properties.
该规范建议使用flex
速记属性。 这有助于编写flex-basis
以及flex-grow
和flex-shrink
属性。
Here is rows of individual flex containers and individual flex elements showing how flex-basis
affects the box-sizing
.
这是单个flex容器和单个flex元素的行,它们显示flex-basis
如何影响box-sizing
。
When the flex-direction
is column
, the same flex-basis
will control the height
property. You can see it in the example below:
当flex-direction
为column
,相同的flex-basis
将控制height
属性。 您可以在以下示例中看到它:
You can fund additional references about the flex basis property on the following pages:
您可以在以下页面上为有关弹性基准属性的其他参考提供资金:
CSS specification
CSS规范
Mozilla Developer Network page on
Mozilla开发人员网络页面
翻译自:
flexbox
转载地址:http://wcuzd.baihongyu.com/