Middle fixed two-sided adaptive three-column layout

Source: Internet
Author: User

The previous layout "Middle self-adaptive two sides fixed" with three methods to solve, this is not a common layout format, look at the solution, first look at the simple solution

The first type: absolute positioning

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title>    <style>Html,body{Height:100%;padding:0;margin:0;}Div{Height:100%;}. Main{width:500px;background:Yellow;position:Absolute;Top:0; Left:50%;Margin-left:-250px;Z-index:5;}. Left,.right{position:Absolute;width:50%; Left:0;Z-index:2;background:Black;}. Right{position:Absolute;width:50%; Right:0;Z-index:2;background:Black;}    </style></Head><Body>    <Divclass= "Left"></Div>    <Divclass= "Main"></Div>    <Divclass= "Right"></Div></Body></HTML>

Very easy to solve

The second type: floating

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title>    <style>Html,body{Height:100%;padding:0;margin:0;}Div{Height:100%;}. Left,.right{width:50%;float: Left;Margin-left:-250px;background:Blue;}. Main{width:500px;float: Left;background:Yellow;}. Right. Inner,.left. Inner{Margin-left:250px;background:#000; }    </style></Head><Body>    <Divclass= "Left">        <Divclass= "inner">This is the left sidebar content</Div>    </Div>    <Divclass= "Main">    </Div>    <Divclass= "Right"> ""        <Divclass= "inner">This is right Siderbar content</Div>    </Div></Body></HTML>

The width of the middle main is fixed, and then let it do the floating, the key is set in the left and right sidebar, this method is to make it all 50% width setting, and add the negative left margin, and then in the left and right sidebar of the inner layer Div.inner it to display the place to pull back, OK

The third type: CSS3 Flex

Middle fixed two-sided adaptive three-column 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.