We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
创建 Flex 容器,inline 或 block 取决于 inline-flex 和 flex,为所有直接子元素创建 flex 上下文
inline
block
inline-flex
flex
.container { display: flex; /* or inline-flex */ }
flex-direction 属性决定主轴的方向(即项目的排列方向)
flex-direction
.container { flex-direction: row | row-reverse | column | column-reverse; }
justify-content 属性定义了项目在主轴(main axis)上的对齐方式
justify-content
.container { justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly; }
与 justify-content 对齐每个 item 的方式类似,align-content 用于对齐交叉轴上的每一行,当 flexbox 只有一行的时候,这个属性不会产生任何效果
align-content
.container { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }
align-items 属性定义项目在交叉轴(cross-axis)上如何对齐
align-items
.container { align-items: flex-start | flex-end | center | baseline | stretch; }
属性定义项目的排列顺序。数值越小,排列越靠前,默认为0
.item { order: <integer>; /* default is 0 */ }
flex-flow: <‘flex-direction’> || <‘flex-wrap’>
align-self 属性允许单个项目有与其他项目不一样的对齐方式,可覆盖 align-items 属性。默认值为 auto,表示继承父元素的 align-items 属性,如果没有父元素,则等同于 stretch
.item { align-self: auto | flex-start | flex-end | center | baseline | stretch; }
CSS 属性 flex 规定了弹性元素如何伸长或缩短以适应 flex 容器中的可用空间。这是一个简写属性,可以同时设置 flex-grow, flex-shrink 与 flex-basis 此属性设置在每一个 item 中
flex-grow
flex-shrink
flex-basis
item
设置或检索弹性盒的扩展比率,0 值表示不拉伸,大于 0 的值表示根据剩余空间和比例,决定应该给项目增加多大的空间
.item { flex-grow: <number>; /* default 0 */ }
设置或检索弹性盒的收缩比率,0 值表示不收缩,大于 0 的值表示根据收缩空间和比例,决定应该给项目压缩多大的空间
.item { flex-shrink: <number>; /* default 1 */ }
设置或检索弹性盒伸缩基准值
.item { flex-basis: <length> | auto; /* default auto */ }
flex-basis 规定的是子元素的基准值。所以是否溢出的计算与此属性息息相关。flex-basis 规定的范围取决于 box-sizing。这里主要讨论以下 flex-basis 的取值情况:
当 item 基准值取 0% 的时候,是把该项目视为零尺寸的,项目设置的宽度不生效
auto:首先检索该子元素的主尺寸,如果主尺寸不为 auto,则使用值采取主尺寸之值;如果也是 auto,则使用值为 content
百分比:根据其包含块(即伸缩父容器)的主尺寸计算。如果包含块的主尺寸未定义(即父容器的主尺寸取决于子元素),则计算结果和设为 auto 一样
默认状态下,伸缩项目不会收缩至比其最小内容尺寸(最长的英文词或是固定尺寸元素的长度)更小。网页作者可以靠设置「min-width」或「min-height」属性来改变这个默认状态
none
auto
initial
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://developer.mozilla.org/zh-CN/docs/Web/CSS/flex
https://segmentfault.com/q/1010000004080910/a-1020000004121373
The text was updated successfully, but these errors were encountered:
No branches or pull requests
# display
创建 Flex 容器,
inline
或block
取决于inline-flex
和flex
,为所有直接子元素创建flex
上下文# flex-direction
flex-direction
属性决定主轴的方向(即项目的排列方向)# justify-content
justify-content
属性定义了项目在主轴(main axis)上的对齐方式# align-content
与
justify-content
对齐每个 item 的方式类似,align-content
用于对齐交叉轴上的每一行,当 flexbox 只有一行的时候,这个属性不会产生任何效果# align-items
align-items
属性定义项目在交叉轴(cross-axis)上如何对齐# order
属性定义项目的排列顺序。数值越小,排列越靠前,默认为0
# flex-flow (Applies to: parent flex container element)
# align-self
align-self 属性允许单个项目有与其他项目不一样的对齐方式,可覆盖 align-items 属性。默认值为 auto,表示继承父元素的 align-items 属性,如果没有父元素,则等同于 stretch
# flex
CSS 属性
flex
规定了弹性元素如何伸长或缩短以适应 flex 容器中的可用空间。这是一个简写属性,可以同时设置flex-grow
,flex-shrink
与flex-basis
此属性设置在每一个
item
中flex-grow
设置或检索弹性盒的扩展比率,0 值表示不拉伸,大于 0 的值表示根据剩余空间和比例,决定应该给项目增加多大的空间
flex-shrink
设置或检索弹性盒的收缩比率,0 值表示不收缩,大于 0 的值表示根据收缩空间和比例,决定应该给项目压缩多大的空间
flex-basis
设置或检索弹性盒伸缩基准值
flex-basis 规定的是子元素的基准值。所以是否溢出的计算与此属性息息相关。flex-basis 规定的范围取决于 box-sizing。这里主要讨论以下 flex-basis 的取值情况:
当 item 基准值取 0% 的时候,是把该项目视为零尺寸的,项目设置的宽度不生效
auto:首先检索该子元素的主尺寸,如果主尺寸不为 auto,则使用值采取主尺寸之值;如果也是 auto,则使用值为 content
百分比:根据其包含块(即伸缩父容器)的主尺寸计算。如果包含块的主尺寸未定义(即父容器的主尺寸取决于子元素),则计算结果和设为 auto 一样
默认状态下,伸缩项目不会收缩至比其最小内容尺寸(最长的英文词或是固定尺寸元素的长度)更小。网页作者可以靠设置「min-width」或「min-height」属性来改变这个默认状态
单值语法
none
,auto
,或initial
双值语法
三值语法
参考
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://developer.mozilla.org/zh-CN/docs/Web/CSS/flex
https://segmentfault.com/q/1010000004080910/a-1020000004121373
The text was updated successfully, but these errors were encountered: