Css3 box-sizing properties, css3box-sizing
Definition and usage
The box-sizing attribute allows you to define specific elements that match a region in a specific way.
For example, if you want to place two boxes with borders side by side, you can set box-sizing to "border-box ". This allows the browser to display a box with a specified width and height, and put the border and padding into the box.
Default Value: |
Content-box |
Inheritance: |
No |
Version: |
CSS3 |
JavaScript Syntax: |
Object. Style. boxSizing = "border-box" |
Box-sizing: content-box | border-box default value: content-box: padding and border are not included in the defined width and height. The actual width of the object is equal to the sum of the Set width value and border, padding, and margin, that is, (Element width = width + border + padding + margin) this attribute is represented in the Box Model in standard mode. Border-box: padding and border are included in the defined width and height. The actual width of the object is equal to the configured width value. Even if border and padding are defined, the actual width of the object is not changed, that is, (Element width = width) this attribute is represented in the Box Model in the weird mode. Example:
<Style type = "text/css"> div {width: 200px; height: 100px; padding: 20px; background: # eee ;}. content-box {box-sizing: content-box;-moz-box-sizing: content-box; border: 10px solid #333 ;}. padding-box {box-sizing: padding-box;-moz-box-sizing: padding-box;-webkit-box-sizing: padding-box; /* chrome does not support */border: 10px solid # ccc ;}. border-box {box-sizing: border-box;-moz-box-sizing: border-box; border: 10px solid #666 ;} </style> <div class = "content-box"> content-box </div> <div class = "padding-box"> padding-box/* chrome does not support * /</div> <div class = "border-box"> border-box </div>