Simple implementation of html footer at the bottom of the page, and htmlfooter at the page

Source: Internet
Author: User

Simple implementation of html footer at the bottom of the page, and htmlfooter at the page

The following is a simple implementation of html footer at the bottom of the page. I think it is quite good. Now I will share it with you and give you a reference. Let's take a look at it with xiaobian!

Requirement: Sometimes, when the page content is short, the browser height is not supported, but footer is expected to be at the lowest end of the window.

Idea: the minimum height of the parent layer of footer is 100%. If footer is set to absolute (bottom: 0) relative to the parent layer, the height of footer should be reserved in the parent layer.

Html code:
 

<! -- Parent layer --> 2. <p id = "wapper"> 3. <! -- Main content --> 4. <p id = "main-content"> 5. </p> 6. <! -- Footer --> 7. <p id = "footer"> 8. </p> 9. </p>

CSS:
 

1. # wapper {2. position: relative;/* important! Ensure that footer is relative to the position of wapper */3. height: auto;/* Ensure that the page is displayed normally when the browser height is enabled */4. min-height: 100%/* IE6 is not supported. IE6 must be configured separately */5 .} 6. # footer {7. position: absolute; bottombottom: 0;/* Key */8. left: 0;/* remember it in IE */9. height: 60px;/* the height of footer must be fixed */10 .} 11. # main-content {12. padding-bottom: 60px;/* important! Space reserved for footer */13 .}

At this time, other browsers can be normally displayed, but IE 6 should be handled separately:


1. <! -- [If IE 6]-> 2. <style> 3. # wapper {height: 100%;}/* the layer is automatically opened when the height of IE is not enough */4. </style> 5. <! [Endif] -->

 

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.