CSS3 Box-sizing Detailed

Source: Internet
Author: User
People slowly realized that the traditional box model was not straightforward, so they added a new one called box-sizingThe CSS property.

box-sizing: Box size, box model.

We often encounter the left and right module width of 50%, add a border will fall down, add a style to solve, look at the chestnut:

<! DOCTYPE html>

The Box-sizing property can be one of three values: Content-box (Default), Border-box,padding-box.

Content-box,border and padding do not count into width

Padding-box,padding calculation into width inside

Border-box,border and padding calculate into the width, in fact, is a strange 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.