CSS Two column three-column layout

Source: Internet
Author: User

I. Three column layout

1. Classic Grail layout (double wing layout)

<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>

  

<div class= "header" >    

2. Absolute Positioning method

<style type= "Text/css" >*{margin:0px;padding:0px;}. left{position:absolute;background-color:orange;width:100px;height:300px;}. Center{height:300px;background-color:blue;text-align:center;}. right{position:absolute;background-color:green;top:0px;right:0px;width:100px;height:300px;} </style><body><div class= "left" >left</div><div class= "center" >center</div> <div class= "right" >right</div></body>

Pros: Three div order can be changed arbitrarily

Cons: Top Values to note

3. Self-floating

<style type= "Text/css" >.left{float:left;background-color:orange;width:100px;height:300px;}. Center{height:300px;background-color:blue;text-align:left;}. right{float:right;background-color:green;width:100px;height:300px;} </style><body><div class= "left" >left</div><div class= "right" >right</div>< Div class= "center" >center</div></body>

Advantage page affects small

Cons: Center must be at the bottom

4.CSS3 new Features

#box {display:flex;width:100%;}. left{background-color:orange;width:100px;height:300px;}. Center{height:300px;background-color:blue;text-align:left;flex:1;}. right{background-color:green;width:100px;height:300px;} </style><body><div id= "box" ><div class= "left" >left</div><div class= "center" > Center</div><div class= "right" >right</div></div>

Flex properties are used to set or retrieve how the child elements of a flexible box model object allocate space.

Flex: flex-grow flex-shrink flex-basis|auto|initial|inherit;

Flex Calculation rule: Calculates the total datum of all child elements first and calculates the remaining space according to the remaining space and the coefficient of allocation than the calculation of the remaining space to obtain the final width

Two. Two Column layout

1.position:absolute;

2.float and margin

Extended

The Calc () function is used to dynamically calculate length values.

CSS Two column 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.