CSS Flex 布局

容器 (Container)
列 (Item)

https://zhuanlan.zhihu.com/p/25303493

<div id="container" > /*容器*/
	<div id="item1" /> /*列*/
	<div id="item2" />
</div>

container的样式

<style>
#container { /*容器的css*/
display: flex;
display: -webkit-flex; /* Safari */
/* 列的方向
row 			默认从左到右
row-reverse 	从右到走
column 			从上到下
column-reverse 	从下到上
 */
flex-direction: row | row-reverse | column | column-reverse;
/* 列是否可以换行
nowrap 			不换行,多余会隐藏
wrap 			换行,自动挤压到下一行
wrap-reverse 	换行,自动将上一行挤压到下一行
*/
flex-wrap: nowrap | wrap | wrap-reverse;
/* flex-direction和flex-wrap的简写
row nowrap
*/
flex-flow: <flex-direction> || <flex-wrap>;
/* 列的左右对齐方式(flex-direction: row)
flex-start 		左对齐
flex-end 		右对齐
center 			居中
space-between	两端对齐
space-around	每列间隔相等(最左边和最右边只有半个间隔)
*/
justify-content: flex-start | flex-end | center | space-between | space-around;
/* 列的上下对齐方式(flex-direction: row)
stretch			自适应,容器的高度就是列的高度
flex-start 		顶部对齐
flex-end 		底部对齐
center 			上下居中对齐
baseline		居于第一个item的文字基线对齐
*/
align-items: stretch | flex-start | flex-end | center | baseline;
/* 列的上下对齐方式(多轴,也就是有了换行)(flex-direction: row, flex-wrap: wrap)
stretch 		自适应,平分容器的高度,平分后的高度就是列的高度
flex-start		顶部对齐,往下排
flex-end 		底部对齐,往上排
center			中间对齐,往下排
space-between	上下两端对齐
space-around	每列间隔相等(最上和最下边只有半个间隔)
*/
align-content: stretch | flex-start | flex-end | center | space-between | space-around;
}

item的样式

#item1 { /*列的css*/
/* 排序值 asc(升序,从小到大)
*/
order: <integer> ;
/* 列的放大比例
*/
flex-grow: <number>;
/* 列的缩小比例
*/
flex-shrink: <number>;
/* 列占容器的大小 (配合flex-grow和flex-shrink使用)
auto 			自适应
<length>		大小
*/
flex-basis: auto | <length>;
/* flex-grow,flex-shrink,flex-basis的简写
*/
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ];
/* 覆盖容器属性align-items
参数见容器的align-items
*/
align-self: auto | stretch | flex-start | flex-end | center | baseline;
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值