box-sizing

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		div{
			width: 160px;
			height: 80px;
			padding: 20px;
			border: 8px solid red;
			background: yellow;
		}
		.content-box{
			box-sizing: content-box;
		}
		.border-box{
			box-sizing: border-box;
		}
	</style>
</head>
<body>
	<div class="content-box">Content box</div><br/>
	<div class="border-box">Border box</div>

	<script>
		/*
		 content-box:
		 This is the initial and default value as specified by the CSS standard. The width and height properties are measured including only the content, but not the padding, border or margin.
		 默认值。宽度和高度属性仅包括内容,不包含内边距,边框和外边距。

		 border-box:
		 The width and height properties include the content, the padding and border, but not the margin.
		 宽度和高度属性包含内容,内边距和边框,但不包含外边距。
		 */ 
	</script>
</body>
</html>



参考链接:

点击打开链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值