您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

css中Flex布局要素的介绍(附代码)

2025/12/25 21:48:26发布24次查看
本篇文章给大家带来的内容是关于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;}
以上就是css中flex布局要素的介绍(附代码)的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product