Css layout learning notes-box-sizing

Source: Internet
Author: User

When you set the width of the element, the actually displayed element can go beyond your setting, because the border and padding of the element will open the element.

{:;:;:;:;}

The effect shown by the above elements is more than Px in width. This may not be what we want. Generally, we may calculate the width to achieve the desired effect. However, if there are too many computing tasks, the events are annoying.

In this case, we can set box-sizing: border-box.

{:;:;:;:;:;:;:;}

In this case, the width displayed by the div is PX, and the outer and inner margins are drawn within the width. In fact, the content width is reduced, and the content width is the set value minus the margin.

Box-sizing: content-box; is the default effect when the box-sizing attribute is not set.

{:;:;:;}

This ensures that all elements are typeset in a more intuitive way.

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.