CSS 盒子尺寸属性
cssweb developmentfront end technology更新于 2025/3/20 1:48:17
box-sizing 属性用于更改元素的高度和宽度。自 CSS2 以来,box 属性的工作方式如下所示:−
width + padding + border = 元素盒子的实际可见/渲染宽度 height + padding + border = 元素盒子的实际可见/渲染高度
示例
为了理解 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/

