站长资讯网
最全最丰富的资讯网站

CSS Flex 的用途详解

CSS Flex 的用途详解

一、可以利用flex来布局一个p在另一个p里面水平垂直居中

如:html代码: 

<p class="container"> 	<p class="box">  	</p> 	</p>

css代码:

.container{ 	width:600px; 	height:400px; 	border:1px solid blue; 	display: flex; 	justify-content:center; 	align-items:center; 	} 	.box{ 	width:200px; 	height:100px; 	border:1px red solid;

ps:这样就可以水平垂直居中咯

二、flex的属性

<p class="items"> 	<p class="item">1</p> 	<p class="item">23</p> 	<p class="item">4</p> 	</p>

可以写在items上的属性有六个:

•flex-direction
•flex-wrap
•flex-flow
•justify-content
•align-items
•align-content

可以写在item上的有6个:

•order//这个就是item单独给了,要是想让那个item调换顺序就给这个属性给那个item
•flex-grow
•flex-shrink
•flex-basis
•flex
•align-self

赞(0)
分享到: 更多 (0)

网站地图   沪ICP备18035694号-2    沪公网安备31011702889846号