Week 4-1 of summer vacation

Source: Internet
Author: User

Yesterday I wrote a mobile phone page. The most important thing to note on the mobile phone page is that the page will change with the size of the mobile phone page, and the mobile phone screen is very small, even a small left and right white space gives a sense of waste and inconsistency.

Therefore, a large number of labels require "width: 100%", but the default algorithm of the element width is "width" = width + padding + margin. The problem it produces is setting width: 100%. with padding and margin, the page on the mobile phone needs to be slide horizontally to see it. I had the honor to experience it. To tell the truth, I felt very bad.

Here I will introduce an element in css3.

                                box-sizing: content-box|border-box|inherit;
Value Description
Content-box

This is the width and height behavior specified by css2.1.

The width and height are respectively applied to the content box of the element.

Draw the padding and border of the element beyond the width and height.

Border-box

The width and height set for the element determine the border box of the element.

That is to say, any padding and border specified for the element will be drawn within the configured width and height.

The width and height of the content can be obtained by subtracting the border and the padding from the configured width and height.

Inherit Specifies that the value of the box-sizing attribute should be inherited from the parent element.

Box-sizing: border-box; attribute: width = "width" + padding + margin. After setting width: 100%, we can set padding and margin as much as possible ~

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.