Home > Web Front-end > HTML Tutorial > css3 box-sizing属性_html/css_WEB-ITnose

css3 box-sizing属性_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:49:29
Original
1450 people have browsed it

Definition and Usage

The box-sizing attribute allows you to define specific elements that match a certain area in a specific way.

For example, if you need to place two bordered boxes side by side, you can do this by setting box-sizing to "border-box". This causes the browser to render a box with the specified width and height, and put the borders and padding into the box.

默认值: 继承性: 版本: JavaScript 语法:
content-box
no
CSS3
object.style.boxSizing="border-box"

box-sizing: content-box | border-box

Default: content-box

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 property behaves like a box model in standard mode.

border-box:

padding and border are included within the defined width and height. The actual width of the object is equal to the set width value. Even if border and padding are defined, the actual width of the object will not be changed, that is (Element width = width)

This attribute behaves like a box model in 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 不支持*/        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 不支持*/</div><div class="border-box">border-box</div>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template