码迷,mamicode.com
首页 > Web开发 > 详细

css-5(弹性盒子)

时间:2018-04-03 17:33:06      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:image   nbsp   css   center   gpo   一个   display   items   http   

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<style type="text/css">
	/*	分别设置father和son的宽高和边框*/
	
		.father{
			width: 1000px;
			height: 500px;
			border: 1px solid black;
			/*在css中设置father为弹性盒子*/
			display: flex;
			/*让father的子元素在father中水平居中
			 justify-content: center;*/
			/*让子元素空间环绕*/
			justify-content: space-around;
			/*让子元素垂直居中*/
			align-items: center;
			/*允许当父系元素宽度小于子元素总宽度时,多余的子系元素换行排列*/
			flex-wrap: nowrap;
		}
		.son{
			/*可去掉son的宽度,使用flex:N(n填写数字)参数,则每个son的宽度占父系宽度的 "N/总N"
			 * flex: N;*/
			width: 200px;
			height: 100px;
			border: 1px solid blue;
		}
	</style>
	<body>
		<!--设置一个父系div,取名叫father-->
		<div class="father">
			<!--设置子div,取名叫son-->
            <div class="son"></div>		
             <div class="son"></div>	
             <div class="son"></div>	
             	
            	
		</div>
	</body>
</html>

 效果图:

技术分享图片

css-5(弹性盒子)

标签:image   nbsp   css   center   gpo   一个   display   items   http   

原文地址:https://www.cnblogs.com/zhangrui0328/p/8708592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!