CSS page layout Getting Started Tutorial 3: A fixed-width Center _ Basic Tutorial

Source: Internet
Author: User
CSS Page layout Getting Started Tutorial 3: A fixed-width Center _ Basic Tutorial

The overall center of the page is the most widely used form of web design, and in the traditional table layout, we use the align= "Center" attribute of the table to implement it. P itself also supports the align= "center" attribute, but also allows p to be centered, but the CSS layout is for the separation of performance and content, while the Align alignment property is a style code that is written in the XHTML p attribute. There is a breach of the sharing principle (separation can make your site more conducive to management), so should be CSS method to achieve the center of content, we use fixed-width column layout code for example, for it to increase the center CSS style:

The code is as follows:

#layout {      border:2px solid #A9C9E2;      Background-color: #E8F5FE;      height:200px;      width:300px;      margin:0px Auto;  }


The margin property controls the margins of the top, right, bottom, and left four directions of an object, and when margin uses two parameters, the first parameter represents the top bottom margin, and the second parameter represents the left margin. In addition to the direct use of numeric values, margin does not support a value called Auto,auto value is to let the browser automatically determine the margin, here, we give the current p left and right margin set to auto, the browser will be P's left and right margin is set to the same, and rendered as the center state, so as to achieve the results.
Note: This method is centered on IE6 the following browsers do not support, behind the CSS hack section to explain the solution.

<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML


The procedure is the same as the fixed width of a column, except that the CSS border setting item sets the top, right, bottom, and left sides of the boundary to 0, auto, 0, auto, respectively.

The above is the CSS page layout Getting Started Tutorial 3: A fixed width of the center of the basic tutorial content, more relevant content please follow topic.alibabacloud.com (www.php.cn)!

  • 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.