1. 分类
-
标准盒子模型 content-box
标准盒子模型 -
怪异盒子模型 border-box
image.png
2. 示例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>盒子模型</title>
</head>
<body>
<style>
.border-box {
box-sizing: border-box;
width: 300px;
height: 300px;
border: 50px solid red;
margin: 50px;
padding: 50px;
}
.content-box {
box-sizing: content-box;
width: 300px;
height: 300px;
border: 50px solid red;
margin: 50px;
padding: 50px;
}
</style>
<div class="border-box">border-box</div>
<div class="content-box">content-box</div>
</body>
</html>
网友评论