The Holy Grail layout and the double-winged layout

Source: Internet
Author: User

The goal of the Holy Grail layout and the two-wing layout are : fixed width of the left and right columns, adaptive in the middle part;

Holy Grail Layout

Holy Grail layout html:

<div class= "wrap" >  <div class= "main" >    I am the main  </div>  <div class= "left" > I'm on the    left  </div>  <div class= "Right" > I'm on the    side  </div></div>

Holy Grail layout css:

* {    margin:0;    Padding:0}.main {    background-color:yellow;    height:100px;    Float:left;    width:100%;}. Left {    background-color:red;    width:200px;    height:100px;    Float:left;     Margin-left:-100%; /*margin Negative margin *    /position:relative;/* offset relative to itself *    /left: -200px;}. Right {    background-color:blue;    width:200px;    height:100px;    Float:left;    Margin-left: -200px; /*margin negative margin */    position:relative;  /* Offset relative to itself *    /right: -200px;   }. Wrap {    padding:0 200px;  /* Parent Setting padding*/}

advantages of the Holy Grail layout:

Causes the primary content column to load first.
Allows any column to be the highest.
No extra div.
Few hack are needed.

Dual Wing layout

Double winged html

<! DOCTYPE html>

Double winged CSS

. main-wrap {    float:left;    width:100%;}. Main {    height:100px;    margin-left:200px;  /* Use Left and right margin positioning */    margin-right:200px;    Background-color:yellow;}. Left {    background-color:red;    width:200px;    height:100px;    Float:left;    Margin-left:-100%;}. Right {    background-color:blue;    width:200px;    height:100px;    Float:left;    Margin-left: -200px;}

Comparison of the Holy Grail layout and the double wing :

1. Two layouts are the main content of the front loading;

2. The layout has similarities, all use the negative margin to layout;

3. Different:

The Grail layout is implemented by setting the padding value and relative positioning of the parent container;

The two-wing layout is to add a div container to main, set the left and right margin of main to achieve;

The Holy Grail layout and the double-winged layout

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.