有关css中Flex布局要素的详细介绍

本篇文章给大家带来的内容是关于css中Flex布局要素的介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

 

flex布局为 “弹性布局”,任何一个元素都可以通过设置css属性 display:flex; webkit内核浏览器为 display: -webkit-flex;
指定元素为Flex布局。
采用Flex布局的元素,称之为”容器”(flex container), 它其中的所有的子元素称之为Flex项目(flex item);

容器的属性

flex-direction

项目的排列方向 选择值:row(默认值:左到右) | row-reverse(右到左) | column(上到下) | column-reverse(下到上)

.box {
     flex-direction: row | row-reverse | column | column-reverse;
}

flex-wrap

定义项目是否要换行 选择值: nowrap(默认值:不换行) | wrap(换行,第一行在上方) | reverse-wrap(换行,第一行在下方)

 .box{
     flex-wrap: nowrap | wrap | wrap-reverse;
   }

flex-flow

是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap

.box {
     flex-flow: <flex-direction> || <flex-wrap>;
   }

justify-content

定义项目在主轴上的对齐方式。选择值flex-start(默认值 左对齐) | flex-end(右对齐) | center(居中) | space-between(两端对齐) | space-around(每个项目间隔相等)

.box {
     justify-content: flex-start | flex-end | center | space-between | space-around;
   }

align-items
定义项目在交叉轴上如何对齐。选择值flex-start(交叉轴的起点对齐) | flex-end(交差轴的终点对齐) | center(交叉轴的中点对齐) | baseline(项目的第一行文字的基线对齐) | stretch(项目未设置高度或设为auto,将占满整个容器的高度)

 .box {
 align-items: flex-start | flex-end | center | baseline | stretch;
 }

align-content
定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。

.box {
 align-content: flex-start | flex-end | center | space-between | space-around | stretch;
 }

项目的属性

order

.item {
  order: <integer>;
}

flex-grow

.item {
  flex-grow: <number>; /* default 0 */
}

flex-shrink

.item {
  flex-shrink: <number>; /* default 1 */
}

flex-basis

.item {
  flex-basis: <length> | auto; /* default auto */
}

flex

.item {
  flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
}

align-self

.item {
  align-self: auto | flex-start | flex-end | center | baseline | stretch;
}
© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容