Css3 box-sizing ., Detailed description of css3box-sizing

Source: Internet
Author: User

Css3 box-sizing ., Detailed description of css3box-sizing

People gradually realized that the traditional box model is not direct, so they added a newbox-sizing.

box-sizing: Box Size, box model.

We often encounter that the width of the left and right modules is 50%, and adding a border will fall down. Adding this style will solve the problem. Let's look at the chestnuts:

<! DOCTYPE html> 

The box-sizing attribute can be one of three values: content-box (default), border-box, and padding-box.

Content-box, border, and padding are not included in width.

Padding-box, and padding is calculated into the width

Border-box, border, and padding are calculated within the width, which is actually a weird mode.

Pears:

<style type="text/css">    .content-box{        box-sizing:content-box;        -moz-box-sizing:content-box;        width: 100px;        height: 100px;        padding: 20px;        border: 5px solid #E6A43F;        background: blue;    }    .padding-box{        box-sizing:padding-box;        -moz-box-sizing:padding-box;        width: 100px;        height: 100px;        padding: 20px;        border: 5px solid #186645;        background: red;                    }    .border-box{        box-sizing:border-box;        -moz-box-sizing:border-box;        width: 100px;        height: 100px;        padding: 20px;        border: 5px solid #3DA3EF;        background: yellow;    }</style>

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.