CSS2 尺寸属性 vs CSS3 盒子尺寸属性
cssweb developmentfront end technology更新于 2024/3/4 23:08:17
让我们了解一下 CSS2 尺寸属性和 CSS3 盒子尺寸属性之间的区别。
CSS2 尺寸属性
<html>
<head>
<style>
.div1 {
width: 200px;
height: 100px;
border: 1px solid green;
}
.div2 {
width: 200px;
height: 100px;
padding: 50px;
border: 1px solid pink;
}
</style>
</head>
<body>
<div class = "div1">TutorialsPoint.com</div></br>
<div class = "div2">TutorialsPoint.com</div>
</body>
</html>
CSS3 box-sizing 属性
<html>
<head>
<style>
.div1 {
width: 300px;
height: 100px;
border: 1px solid blue;
box-sizing: border-box;
}
.div2 {
width: 300px;
height: 100px;
padding: 50px;
border: 1px solid red;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class = "div1">TutorialsPoint.com</div></br>
<div class = "div2">TutorialsPoint.com</div>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

