Example of css two-column layout (compatible with ie, ff, 360)

Source: Internet
Author: User
Tags wrapper

I. Fixed-width layout

1. The sidebar is on the left.

The code is as follows: Copy code
<Div id = "wrapper">
<Div id = "header"> header </div>
<Div id = "container" class = "cls">
<Div id = "aside">
<Div class = "inner"> aside </div>
</Div>
<Div id = "main">
<Div class = "inner"> main </div>
</Div>
</Div>
<Div id = "footer"> footer </div>
</Div>
# Header {width: 980px; height: 90px; margin: 0 auto; background: # f60 ;}
# Container {width: 980px; height: 500px; margin: 0 auto ;}
# Aside {float: left; width: 240px; height: 500px; background: # ccc ;}
# Main {float: left; width: 740px; height: 500px; background: orange ;}
# Footer {width: 980px; height: 90px; margin: 0 auto; background: # 08f ;}

Effect

 


2. Right-side navigation pane

The code is as follows: Copy code
<Div id = "wrapper">
<Div id = "header"> header </div>
<Div id = "container" class = "cls">
<Div id = "main">
<Div class = "inner"> main </div>
</Div>
<Div id = "aside">
<Div class = "inner"> aside </div>
</Div>
</Div>
<Div id = "footer"> footer </div>
</Div>
# Header {width: 980px; height: 90px; margin: 0 auto; background: # f60 ;}
# Container {width: 980px; height: 500px; margin: 0 auto ;}
# Main {float: left; width: 740px; height: 500px; background: orange ;}
# Aside {float: left; width: 240px; height: 500px; background: # ccc ;}
# Footer {width: 980px; height: 90px; margin: 0 auto; background: # 08f ;}

Effect

 


II. Adaptive layout

1. Fixed adaptive settings on the right of the left column

The code is as follows: Copy code
<Div id = "wrapper">
<Div id = "header"> header </div>
<Div id = "container" class = "cls">
<Div id = "aside">
<Div class = "inner">
Aside
<Br> <br> <br>
</Div>
</Div>
<Div id = "main">
<Div class = "inner">
Main
<Br> <br> <br>
</Div>
</Div>
</Div>
<Div id = "footer"> footer </div>
</Div>
# Header {width: 96%; height: 90px; margin: 0 auto; background: # f60 ;}
# Container {width: 96%; margin: 0 auto ;}
# Aside {float: left; width: 240px; background: # ccc ;}
# Main {margin-left: 240px; background: orange ;}
# Footer {width: 96%; height: 90px; margin: 0 auto; background: # 08f ;}

Effect

 


2. Fixed adaptive settings on the left of the right bar

The code is as follows: Copy code

<Div id = "wrapper">
<Div id = "header"> header </div>
<Div id = "container" class = "cls">
<Div id = "main">
<Div class = "inner">
Main
<Br> <br> <br>
</Div>
</Div>
<Div id = "aside">
<Div class = "inner">
Aside
<Br> <br> <br>
</Div>
</Div>
</Div>
<Div id = "footer"> footer </div>
</Div>

# Header {width: 96%; height: 90px; margin: 0 auto; background: # f60 ;}
# Container {width: 96%; height: 500px; margin: 0 auto ;}
# Main {float: left; width: 100%; background: orange ;}
# Main. inner {padding-right: 240px ;}
# Aside {float: left; width: 240px; margin-left:-240px; background: # ccc ;}
# Footer {width: 96%; height: 90px; margin: 0 auto; background: # 08f ;}

Effect

 

Related Article

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.