Css3 box-sizing attribute specifies the Box Model

Source: Internet
Author: User

Speaking of the IE bug, a notorious example is its explanation of the "Box Model" error: In ie5.x and IE6/7 in quirks mode
Border and padding are both included in width. This poses a lot of trouble for front-end engineers. There are several users who need to define the size of each box.
Do you have to think about it: Have you triggered the "Box Model bug "?

At the same time, because another browser complies with the standard, we also need to calculate when precisely defining a box displayed in a limited space: the space left for it is only that large, how much should we write the width of border and padding?

This situation has been improved in the css3 era, thanks to this attribute called box-sizing, which has two values: "content-box" and "border-box.

When defining box-sizing: Content-box, the browser's interpretation of the box model follows the W3C standards we have previously recognized;

When defining box-sizing: border-box;, the browser interprets the box model as IE6;


Why is this attribute "too late? IE's interpretation of the box model does not comply with W3C specifications, but it also has its advantages: No matter how you change the border and padding values, it will not change the total size of the box, this will not disrupt the overall layout of the page. In FirefoxModern
In the browser, if we want to change the padding value, we have to recalculate the width of the box. Now IE6 is dead, and this CSS attribute is too late.

Use this new property. For Firefox, use-moz-box-sizing. For Safari/WebKit, use-WebKit-box-sizing. For opera, use box-sizing directly.

 

 

------

Enet power in Silicon Valley
> School Channel
> CSS design


This is a good place to learn.

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.