Свойство Style boxSizing
Пример
Измените свойство boxSizing:
document.getElementById("myDIV").style.boxSizing = "border-box";
Определение и использование
Свойство 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: свойство box-sizing
❮ Объект стиля