Style boxSizing- Eigenschaft
Beispiel
Ändern Sie die Eigenschaft boxSizing:
document.getElementById("myDIV").style.boxSizing = "border-box";
Definition und Verwendung
Mit der Eigenschaft boxSizing können Sie bestimmte Elemente so definieren, dass sie auf eine bestimmte Weise in einen Bereich passen.
Wenn Sie beispielsweise zwei umrandete Boxen nebeneinander haben möchten, können Sie dies erreichen, indem Sie boxSizing auf "border-box" setzen. Dadurch wird der Browser gezwungen, die Box mit der angegebenen Breite und Höhe darzustellen und den Rahmen und die Füllung innerhalb der Box zu platzieren.
Browser-Unterstützung
Property | |||||
---|---|---|---|---|---|
boxSizing | Yes | Yes | Yes | Yes | Yes |
Syntax
Geben Sie die boxSizing-Eigenschaft zurück:
object.style.boxSizing
Legen Sie die boxSizing-Eigenschaft fest:
object.style.boxSizing = "content-box|border-box|initial|inherit"
Eigenschaftswerte
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 |
Technische Details
Standardwert: | Inhaltsfeld |
---|---|
Rückgabewert: | Ein String, der die Box-Sizing-Eigenschaft eines Elements darstellt |
CSS-Version | CSS3 |
Verwandte Seiten
CSS-Referenz: Box-Sizing-Eigenschaft
❮ Style-Objekt