Double Flying Wing layout deduction

Source: Internet
Author: User

Careful analysis of the technical implementation of the various layouts reveals that these three techniques are often used: floating (float), negative margin (negative margin), relative positioning (relative position). This is the implementation of the layout of the three most basic atomic technology, as long as the smart combination, and flexible use, you can "spell" the layout of the implementation of the scheme.

The two-wing layout is a flexible layout implementation, if the three column layout compared to a large bird, you can think of main as a bird body, sub and extra is the wings of birds. The idea for this layout is to put the most important parts of the body in place, and then move the wings to the right places.

consider the following DOM structure:  

<DivID= "page">          <DivID= "HD"></Div>             <DivID= "BD">                      <Divclass= "Main"></Div>                      <Divclass= "Sub"></Div>                      <Divclass= "Extra"></Div>             </Div>         <DivID= "FT"></Div></Div>

use the negative margin of the floating element to locate:

. Main{float: Left;width:100%; }  
. Sub{float: Left;width:190px;Margin-left:-100%;
}
. Extra{float: Left;width:190px;Margin-left:-190px; }

So we get the first practice page, the effect is as follows:    

As you can see, with a simple negative margin, the sub and the extra are positioned to the correct position. The remaining question is how to get main to the correct location. A natural idea is to add padding to Main's container #bd:

{                  padding: 0 230px 0 190px;    }

 The effect is as follows: 

This allows the main to be positioned in the correct position, but the sub and extra are not in the right position. This is a level of thinking. Now that the sub and extra are in the wrong place, try to adjust to the right position. Relative positioning Grand Debut:

. Sub{float: Left;width:190px;Margin-left:-100%;position:relative; Left:-190px; }. Extra{float: Left;width:230px;Margin-left:-230px;position:relative; Right:-230px; }

  The final results are as follows:

Double Flying Wing layout deduction

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.