Div + CSS three-column layout

Source: Internet
Author: User

1. Requirements: for example, the layout of the three columns in the middle is the width of the adaptive browser, the left fixed width 200px, And the right fixed width 200px;

. Right,. Left{Height:300px;Width:200px;}. Right{Float:Right;Background:#000000;}. Left{Float:Left;Background:#009933;}. Main{Background:# F60;Height:300px;}
      < Div  Class  = "Right"  > Right </  Div  >      <  Div  Class  = "Left"  > Left </  Div  >      <  Div Class  = "Main"  > Main </  Div  >     

2. Now we need to load Mian First. Other requirements are the same as above;

Conclusion: It mainly uses the negative margin of floating elements;

In addition, to understand float and absolute positioning, the width of these two elements is based on the width of the content.

For relative positioning and block-level elements, if no fixed width is set, the values are 100% (relative to the parent-Level Width)

Download demo

 . Boxmain { Float : Left ;Margin-Right : -200px ; Width : 100% ;} . Right,. Left { Height : 300px ; Width : 200px ; Z-Index : 1 ;} . Right { Position :Absolute ; Right : 0 ; Background : #000000 ;} . Left { Position : Absolute ; Left : 0 ; Background : #009933 ;} . Main {Margin-Right : 200px ; Background : # F60 ; Height : 300px ; Margin-left : 200px ;}

 

 <  Div  Class  = "Boxmain"  >          < Div  Class  = "Main"  > Main </  Div  >          </  Div  >      <  Div  Class  = "Left"  > Left </  Div >      <  Div  Class  = "Right"  > Right </  Div  > 

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.