boxSizing 属性允许您定义某些元素以某种方式适应区域。
例如,如果您想要两个并排的边框框,可以通过将 boxSizing 设置为 "border-box" 来实现。这会强制浏览器渲染具有指定宽度和高度的框,并将边框和内边距放置在框内。
Property | |||||
---|---|---|---|---|---|
boxSizing | Yes | Yes | Yes | Yes | Yes |
返回 boxSizing 属性:
object.style.boxSizing
设置 boxSizing 属性:
object.style.boxSizing = "content-box|border-box|initial|inherit"
Value | Description |
---|---|
content-box | Default value. This is the behavior of width and height as specified by CSS2.1. The specified width and height (and min/max properties) apply to the width and height respectively of the content box of the element. The padding and border of the element are laid out and drawn outside the specified width and height |
border-box | The specified width and height (and min/max properties) on this element determine the border box of the element. That is, any padding or border specified on the element is laid out and drawn inside this specified width and height. The content width and height are calculated by subtracting the border and padding widths of the respective sides from the specified 'width' and 'height' properties |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
默认值: | 内容框 |
---|---|
返回值: | 一个字符串,表示元素的 box-sizing 属性 |
CSS版本 | CSS3 |
CSS 参考:盒子大小属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!