示例工程 08-box-model
08-box-model/demo-01-box-sizing/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>content-box 与 border-box</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>content-box 与 border-box</h1>
<p>两个盒子都写 width: 240px、padding: 20px、border: 4px。</p>
<div class="row">
<div class="box content">content-box<br /><small>实际 288px</small></div>
<div class="box border">border-box<br /><small>实际 240px</small></div>
</div>
</body>
</html>