search
HomeWeb Front-endHTML TutorialCSS Layout Holy Grail Layout & Double Flying Wing Layout_html/css_WEB-ITnose

According to my understanding, in fact, the purpose of realizing the Holy Grail layout and the double flying wing layout is to fix the width of the left and right columns and adapt the middle part.

But there are still some differences in implementation here

[Holy Grail Layout]

Here, the left (200px) and right (220px) widths are fixed, the middle is adaptive, and the container part height remains consistent.

DEMO

A little explanation:

The middle part of the html code must first be placed at the front of the container. Then left, right

1.Add float:left to all three, plus position:relative (because relative positioning will be used later)

2.Middle part width: 100% occupied

3.The middle is full at this time, so you need to pull the left to the far left and use margin-left: -100%

4.At this time, the left is pulled back, but it will cover the left end of the middle content. To pull the middle content out, add padding: 0 220px 0 to the outer container 200px

5.The middle content has been pulled back, but the left has also followed, so to restore it, use relative positioning left:-200px For the same reason, right should also be positioned relatively Restore right:-220px

6.It’s probably adaptive at this point. If you want the container height to be consistent, you can add min-height:130px

to both left, middle and right. However, I found out that there is a problem in IE.. The height of the lower space in IE6/7/8/9 is not the same. Same...

Of course, in order to ensure that the window cannot be reduced too small to display the left and right sides, you can add min-width to the body

Okay, thanks for the code Top:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>圣杯布局</title><style type="text/css">    *{margin: 0;padding: 0;}    body{min-width: 700px;}    .header,    .footer{         border: 1px solid #333;        background: #aaa;        text-align: center;    }    .left,    .middle,    .right{         position: relative;        float: left;        min-height: 130px;    }    .container{        padding:0 220px 0 200px;        overflow: hidden;    }    .left{        margin-left: -100%;        left: -200px;        width: 200px;        background: red;    }    .right{        margin-left: -220px;        right: -220px;        width: 220px;        background: green;    }    .middle{         width: 100%;        background: blue;        word-break: break-all;    }    .footer{         clear: both;    }</style></head><body><div class="header">    <h4 id="header">header</h4></div><div class="container">    <div class="middle">        <h4 id="middle">middle</h4>        <p>HHHHHHHHHHHHHHHHHHHHHH        hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh        HHHHHHHHHHHHHHHHHHHHHH        hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh        </p>    </div>    <div class="left">    <h4 id="left">left</h4>        <p>oooooooooooooo        0000000000000000        00000000000000000        ooooooooooooooo        ooooooooooooooo        000000000000000</p>    </div>    <div class="right">    <h4 id="right">right</h4>        <p>BBBBBBBBBBBBBB        888888888888888888        BBBBBBBBBBBBBBBBBB        88888888888888888888</p>    </div>    </div>    <div class="footer">        <h4 id="footer">footer</h4>    </div></body></html>

[Double flying wing layout]

DEMO

I heard that the double-flying wing layout was proposed by Uncle Yu and started with Taobao UED

If you combine three The column layout is compared to a big bird. You can think of main as the body of the bird, and sub and extra as the wings of the bird. The idea of ​​​​implementing this layout is to first place the most important body parts, and then move the wings to the appropriate place.

In fact, it is similar to the Holy Grail layout above. Of course, you can also change it (if you want) Think about the difference)

Well, there is a bird here~

The sub of the left wing is 200px, and the right wing is extra..220px.. The main adaptation of the body is unknown.

1.In the html code, main should be placed at the front, sub extra

2.Main sub extra should be float:left

3.Fill the main with width: 100%

4.At this time, the main is full, so you need to pull the sub to the far left. Use margin-left:-100% Similarly, use margin-left:-220px for extra

(You can directly continue the steps of the holy grail layout above, or you can make changes)

5.The main content has been covered. In addition to using peripheral padding, you can also consider using margin.

Add an inner div to main-- main-inner, and then margin: 0 220px 0 200px

6.main displays the

code correctly Sincerely:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>双飞翼布局</title><style type="text/css">    *{margin: 0;padding: 0;}    body{min-width: 700px;}    .header,    .footer{         border: 1px solid #333;        background: #aaa;        text-align: center;    }    .sub,    .main,    .extra{         float: left;        min-height: 130px;    }    .sub{        margin-left: -100%;        width: 200px;        background: red;    }    .extra{        margin-left: -220px;        width: 220px;        background: blue;    }    .main{         width: 100%;    }    .main-inner{         margin-left: 200px;        margin-right: 220px;        min-height: 130px;        background: green;        word-break: break-all;    }    .footer{         clear: both;    }</style></head><body><div class="header">    <h4 id="header">header</h4></div>    <div class="main">    <div class="main-inner">        <h4 id="main">main</h4>        <p>HHHHHHHHHHHHHHHHHHHHHH        hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh        HHHHHHHHHHHHHHHHHHHHHH        hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh        </p>        </div>    </div>     <div class="sub">    <h4 id="sub">sub</h4>        <p>oooooooooooooo        0000000000000000        00000000000000000        ooooooooooooooo        ooooooooooooooo        000000000000000</p>    </div>      <div class="extra">    <h4 id="extra">extra</h4>        <p>BBBBBBBBBBBBBB        888888888888888888        BBBBBBBBBBBBBBBBBB        88888888888888888888</p>    </div>    <div class="footer">        <h4 id="footer">footer</h4>    </div></body></html>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.