Css+div Adaptive Height layout

Source: Internet
Author: User
css| Self Adaptation

To achieve the head foot fixed, the middle area with the content is highly adaptive, drag the scroll bar foot forever bottom.



Solardreamstudios 's plan gave me a very good idea, but the key part is original, always thought that will be better than the Solardreamstudios scheme, the results of a careful look at their code, only to find that in fact the principle is almost, But they seem to be doing more with compatibility, not testing.

A. Width 100% Adaptive

Structure code

<body>

<div id= "Head" >head</div>
<div id= "Head_height" ></div>

<div id= "Middle" ></div>

<div id= "Foot_height" ></div>
<div id= "Foot" >foot</div>

</body>
Performance code
#head {width:100% text-align:center; background: #FF9400; height:100px; position:absolute; top:0;}
#head_height {height:100px;}
#middle {margin:20px;}
#foot {width:100% text-align:center; background: #f00; height:100px; position:absolute; bottom:0;}
* HTML #foot {bottom:-1px;}
#foot_height {height:100px;}

B. Width Fixed center

Structure code
<body>

<div id= "Head" >
<div id= "Head_content" >head</div>
</div>
<div id= "Head_height" ></div>

<div id= "Middle" ></div>

<div id= "Foot_height" ></div>
<div id= "Foot" >
<div id= "Foot_content" >foot</div>
</div>

</body>
Performance code
#head {width:100%; text-align:center; position:absolute; top:0; left:0;}
#head_content {line-height:100px width:700px; margin:0 auto; background: #FF9400; height:100px;}
#head_height {height:100px;}
#middle {margin:20px;}
#foot {width:100%; text-align:center; position:absolute; bottom:0;}
* HTML #foot {bottom:-1px;}
#foot_content {line-height:100px width:700px; margin:0 auto; background: #f00; height:100px;}
#foot_height {height:100px;}
Test environment IE6.0 and FF1.5,IE environment because bugs sometimes automatically appear as scrollbars (the Solardreamstudios scheme), FF is the perfect 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.