CSS multi-column layout (instance)

Source: Internet
Author: User

Objective

    1. A list of layouts
    2. Two-Column layout
    3. Three-column layout

11 Column Layout
  • A list of layouts:
    HTML Section<! DOCTYPE html>Head><meta charset="Utf-8"/><title> a column Layout </title></Head><body><div class="Head">Head</div><div class="Main">main</div><div class="Foot">foot</div></body>CSS Section Div{text-Align:center;}.Head{height:60px;background-color: #fae1e1;}. Main{margin:0auto;height:300px;background-color: #e6686a;}. Foot{margin:0auto;background-color:red;}

  • As follows:

22 Column Layout
  • The two-column layout code is as follows (that is, left and right layout), the two-column layout has several methods, float+margin (fixed width on one side, auto on one side), Position+margin (fixed width on one side, auto on one side), float+ negative margin (one side is fixed wide, one side is automatic) etc. This article uses the percentage that sets the width of the two columns, and the adaptive Change code with the width is as follows:
    HTML Section<! DOCTYPE html>Head><title> two column Layout </title></Head><body><div class="Main"><div class=" Left">left</div><div class=" Right">right</div></div></body></htmlcss part body{margin:0; Padding0; font-size:20px; font-weight:bold}div{Text-align:center; line-height:50px}.main{Width: the%; height:400px; Margin0auto}.left{Width: -%; height:400px; Background: #e6686a;float: left}.right{Width: the%; height:400px; Background: #fae1e1;float: Right}

  • As follows:

33 Column Layout
  • Three-column layouts (that is, left-to-right layout), three-column layouts are available in several ways, float+margin (fixed width on both sides, intermediate adaptive), position+margin (fixed width on both sides, Middle adaptive), float+ negative margin (width on both sides, intermediate adaptive), float+ Position+margin (both sides of automatic, middle fixed width), position+margin (both sides of automatic, middle width), this article is float+margin (both sides of the fixed width, the middle adaptive), the code is as follows:
    HTML Section<! DOCTYPE html>Head> <meta charset="Utf-8"> <title>js bin</title></Head><body><div class=" Left">left</div><div class="Center">main</div><div class=" Right">right</div></body>CSS Section body{margin:0; Padding0; font-weight:bold}div{ Line-height:40px}.left{height:400px; width:200px; Position:absolute ; Left:0; Top0; background: #fae1e1;}. right{height:400px; width:200px; position:absolute; Top:0; Right:0;; background: #fae1e1}.center{height:400px; margin:0200px; Background: #e6686a}

  • As follows:

CSS multi-column layout (instance)

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.