Upper and lower structure div CSS Layout instance

Source: Internet
Author: User

Lower structure div CSS layout above instance layout

The upper and lower structure for the common layout structure, general (corporate website) page We can be broadly divided into upper (head), Medium (content area), under (bottom copyright) composition. And this is actually the simplest up and down structure of the CSS layout evolved, but more than a div layer structure and the essence of the layout method is not changed.

first, the main thinking-TOP

Regardless of how many upper or lower structure or single structure, the general body content is centered, this use requires the use of CSS margin style (so that the layout is centered compatible with the major browsers), while the general Web page will be fixed width, that is, to use CSS width to set the width of each div layer.

Here the three upper and lower structure of the div box is actually a sibling relationship, from top to bottom three div layers, just centered.

Second, layout example thinking-TOP

1. Layout to use to style
margin:0 Auto:css Layout Center function
Width setting widths
Border border style for this case easy to observe and add CSS style, the actual project layout according to the need to increase or decrease
Height setting is also the height style set for this case to observe each div layer, and the general structure layout does not need to be set to height, because the general layout does not set the height if the content is too much to be determined.

2, the specific style value
margin:0 Auto (div center function)
width:400px (set width to 400px)
border:1px solid #F00; border:1px solid #FF0; BORDER:1PX Solid #00F (set 3 border with red, yellow and blue respectively)
height:100px;height:200px;height:100px setting three CSS height values

Iii. Complete code of the example-TOP

DIVCSS5 Complete case test or production, Shanghai treatment of premature ejaculation hospital generally do the initial template based on, so as not to be compatible with different browsers. Here do DIVCSS5 provide DIVCSS5 initialization template on the basis of continuation.

The upper and lower names are header, content, footer, because of the structure layout, so to form the general structure of the use of ID, so the CSS naming time to choose the symbol "#".

1, the case corresponding CSS code

    1. #header, #content, #footer {margin:0 auto;width:400px; height:100px}
    2. /* Above code set three common styles */
    3. #header {border:1px Solid #F00}
    4. #content {border:1px solid #FF0; height:200px}
    5. #footer {border:1px Solid #00F}

Code Description:
The first row of the CSS code above, representing the three common center, width, height style, the following three sets the upper (header) Red border, the medium (content) yellow border, the bottom (footer) blue border.

2, the case corresponding to the HTML code

  1. <div id="header"></div>
  2. <div id="Content"></div>
  3. <div id="Footer"></div>

3. Final effect


Upper and lower structure div+css layout browser effect

4. Full HTML code

  1. <! DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <Meta charset="utf-8" />
  5. <title> Upper and lower structure Shanghai impotence Treatment Hospital Online demo </title>
  6. <link href="images/style.css" rel="stylesheet" type= "Text/css"/>
  7. <!--www.divcss5.com--
  8. </head>
  9. <body>
  10. <div id="header"></div>
  11. <div id="Content"></div>
  12. <div id="Footer"></div>
  13. </body>
  14. </html>

5. Full CSS Code

    1. @charset "Utf-8";
    2. Body, div{margin:0; padding:0;font-style:normal;
    3. font:12px/22px "\5b8b\4f53", Arial, Helvetica, Sans-serif}
    4. Body{color: #000000; background: #FFF; Text-align:center}
    5. A{color: #000000; Text-decoration:none}
    6. A:hover{color: #BA2636; Text-decoration:underline}
    7. #header, #content, #footer {margin:0 auto;width:400px; height:100px}
    8. /* Above code set three common styles */
    9. #header {border:1px Solid #F00}
    10. #content {border:1px solid #FF0; height:200px}
    11. #footer {border:1px Solid #00F}

Upper and lower structure div CSS Layout instance

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.