很好用的flex布局汇总

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.menu{
				display: flex;
				
				/*-------------------水平方向-----------------------------*/
				
				justify-content: center;					
				/*居中*/
				justify-content: space-between;				
				/*两端对齐,项目之间的间隔都相等。*/
				justify-content: space-around;				
				/*每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍。*/
				justify-content: flex-start;				
				/*左对齐*/
				justify-content: flex-end;					
				/*右对齐*/
				
				/*-------------------垂直方向-----------------------------*/
				align-items: center;					
				/*垂直在中间前端居中*/
				align-items: flex-start;					
				/*交叉轴的起点对齐。*/
				align-items: flex-end;						
				/*交叉轴的终点对齐。*/
				align-items: baseline;						
				/*项目的第一行文字的基线对齐。*/
				align-items: stretch;						
				/*如果项目未设置高度或设为auto,将占满整个容器的高度。*/
							
				/*1.flex-diirection属性*/
				flex-direction: column;					
				/*主轴为垂直方向,起点在上沿。*/
				flex-direction: column-reverse;			
				/*主轴为垂直方向,起点在下沿。*/
				flex-direction: row-reverse;			
				/*主轴为水平方向,起点在右端。*/
				flex-direction: row; 					
				/*主轴为水平方向,起点在左端。*/
				/*2.flex-wrap属性*/	
				flex-wrap: nowrap;							
				/*默认,不换行*/
				flex-wrap: wrap;							
				/*换行,第一行在上方。*/
				flex-wrap: wrap-reverse;					
				/*换行,第一行在下方。*/					
				width: 900px;
				height: 500px;
				background-color: #FFFFFF;
			}
			.item{
				width: 100px;
				height: 100px;
				/*background-color: red;*/
			}
			.item1{
				background-color:bisque;
			}
			.item2{
				background-color: red;
			}
			.item3{
				background-color: yellow;
			}
			.item4{
				background-color: green;
			}
		</style>
	</head>
	<body>
		<div class="menu">
			<div class="item item1"></div>
			<div class="item item2"></div>
			<div class="item item3"></div>
			<div class="item item4"></div>
		</div>
	</body>
</html>

特别注意:要在父类里面写,子类至少有两个

转载于:https://my.oschina.net/u/3883702/blog/1862188

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值