IFE Learning notes <1> CSS Layout tips

Source: Internet
Author: User

#main {    max-width:600px;     margin:0 auto;}

Replace width with max-width to automatically adjust the content width when the screen is narrower than 600px, instead of the wheel. All major browsers including IE7 are supported.

* {    -webkit-box-sizing:border-box;        -moz-box-sizing:border-box;             box-sizing:border-box;}

Avoid padding and border-width to keep the elements wide. Eliminate the usual mathematical calculations, making the width of the same element as wide. Support ie8+.

. Clearfix {    overflow: auto;     Zoom: 1; //added to support IE6, triggering haslayout}

A closed float, which is better than clear floating, solves the problem of floating elements that are higher than the containing element and thus overflow. The class= "Clearfix" that contains the element.

{    nav {        float: left;         Width: 25%;    } {margin-left: 25%;        }          {    nav li {        display: inline;    } }

Media queries for responsive layouts.

. Box {    display: inline-block;     width:200px;     height:100px;     margin:1em;}

Inline-block, there will also be a response type.

"You can use inline-block to layout. There are some things you should keep in mind:

    • vertical-alignproperty affects the inline-block element, you may set its value to top .
    • You need to set the width of each column
    • If there are spaces between the elements in the HTML source code, there is a gap between the columns and columns.

IFE Learning notes <1> CSS Layout tips

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.