CSS3宽高属性值

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{margin: 0;padding: 0;}
			.box{
				width:600px;
				height: 100px;
				background: red;
				margin: 100px auto;
				
			}
			.box1{
				height: 50px;
				background: pink;
				width: -webkit-fill-available;/*让元素的宽度与父元素宽度一致*/
			
			}
			
			.con{
				width:fit-content;/*内容撑起的宽度*/
				height: 300px;
				background: red;
				margin:100px auto;
			}
			
			/*子元素不确定有多少个,那父元素不好设置宽度,又想居中显示*/
			.con1{
				width:100px;
				height: 100px;
				background: pink;
				margin:10px;
				float:left;
				
			}
			
			/*max-content*/
			.main1{
				
				width: min-content;
				width: max-content;
				height: 100px;
				background: pink;
				margin: 100px;
				padding:20px;
			}
			.con3{
				width:200px;
				height:50px;
				background: red;
				margin: 10px;
			}
		</style>
	</head>
	<body>
		<!--
			width:; height:;
				-webkit-fill-available	
					让元素自适应父元素的宽度或者高度
				fit-content 让一个元素适应内容的一个宽度
					
				max-content 适应元素撑起来的最大宽度/最大高度
				min-content 适应元素撑起来的最小宽度/最小高度
		-->
		<div class="box">
			<div class="box1"></div>
		</div>
		
		<div class="con">
			<div class="con1"></div>
			<div class="con1"></div>
			<div class="con1"></div>
		</div>
		
		<div class="main1">
			更新中!更新中!更新中!更新中!更新中!
			<div class="con3"></div>
			<div style="width:100px;height:30px;background:blue;"></div>
		</div>
	</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值