Css3 box-sizing properties, css3box-sizing

Source: Internet
Author: User

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>

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.