CSS box models (box model)

Source: Internet
Author: User

The so-called box model is to treat HTML elements as a box. In daily life, boxes are the most common items. For example, a box of mooncakes, there are outside the box, inside is a general iron box, and then the inside is the plastic or paper packaging, a box of large packaging has several small packaging. As a matter of principle, each label in HTML is considered a box with a type, and the label can be seen as a box-to-box relationship.

Box Model composition: content: What elements are going to present

Padding (padding): The distance between content and borders

Border (border)

Margin (margin): The distance between boxes

The width and Height properties are the widths and heights of content, not the width and height of the element.

Element width = left margin + left border + left padding +width+ right padding + right margin

Height of element = Top margin + top border + top padding +height+ bottom padding + bottom border + bottom margin

It is inferred from the above formula that you can set the properties of each edge individually (in a clockwise direction).

For example: padding:10px; (equivalent to set to padding:10px 10px 10px 10px;)

padding:10px 20px; (equivalent to: padding:10px 20px 10px 20px;)

padding:10px 15px 20px; (equivalent to: padding:10px 15px 20px 15px;)

Other margin and border the same.

CSS box models (box model)

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.