Pole styluSizing Property
Przykład
Zmień właściwość boxSizing:
document.getElementById("myDIV").style.boxSizing = "border-box";
Definicja i użycie
Właściwość boxSizing pozwala zdefiniować pewne elementy, aby dopasować je do obszaru w określony sposób.
Na przykład, jeśli chcesz mieć dwa obramowane pola obok siebie, możesz to osiągnąć poprzez ustawienie boxSizing na "border-box". Zmusza to przeglądarkę do renderowania pudełka o określonej szerokości i wysokości oraz umieszczania obramowania i dopełnienia wewnątrz pudełka.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
boxSizing | Yes | Yes | Yes | Yes | Yes |
Składnia
Zwróć właściwość boxSizing:
object.style.boxSizing
Ustaw właściwość boxSizing:
object.style.boxSizing = "content-box|border-box|initial|inherit"
Wartości nieruchomości
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 |
Szczegóły techniczne
Domyślna wartość: | zawartość-box |
---|---|
Wartość zwrotu: | String, reprezentujący właściwość box-sizing elementu |
Wersja CSS | CSS3 |
Powiązane strony
Odniesienie CSS: właściwość rozmiaru pudełka
❮ Obiekt stylu