实例代码
xxxxxxxxxx
<html>
<head>
<meta charset="utf-8">
<title>开创者教程(kaicz.com)</title>
<style>
.box {
box-sizing: border-box;
width: 200px;
height: 100px;
background-color: #ff6347;
color: white;
padding: 20px;
border: 2px solid #333;
}
.content {
background: rgba(255, 255, 255, 0.2);
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<h1>CSS padding属性示例</h1>
<div class="box">
<div class="content">默认情况下(box-sizing: content-box)</div>
</div>
<p>浏览器默认使用替代盒模型时:</p>
<p>此元素总宽度 = 内容宽度(200px)</p>
<p>此元素总高度 = 内容高度(100px)</p>
</body>
</html>