<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>怪異盒模型與標準盒模型的區(qū)別</title>
<style type="text/css">
html,body,div,p{padding: 0;margin: 0;}
.borderBox{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
div{
width: 200px;
height: 200px;
padding: 10px;
border: 10px solid #000;
margin: 10px;
}
</style>
</head>
<body>
<div class="borderBox">
<p>我是怪異盒模型</p>
<p>盒子總寬度包含內(nèi)邊距和邊框,盒子總寬度不會根據(jù)邊框和內(nèi)邊距發(fā)生變化</p>
<p>內(nèi)容 = 寬度 - 內(nèi)邊距 - 邊框 </p>
<p>160 = 200-10*2-10*2</p>
</div>
<div>
<p>我是標準盒模型</p>
<p>盒子寬度為內(nèi)容寬度,總寬度為內(nèi)容寬度加內(nèi)邊距和邊框,根據(jù)內(nèi)邊距和邊框變化</p>
<p>寬度 = 內(nèi)容 + 內(nèi)邊距 + 邊框</p>
<p>240 = 200 + 20 + 20</p>
</div>
</body>
</html>

怪異盒模型與標準盒模型的區(qū)別.jpg