Sticky Footer (let the Footer always stop at the bottom of the page, instead of based on the absolute position), stickyfooter

Source: Internet
Author: User

Sticky Footer (let the Footer always stop at the bottom of the page, instead of based on the absolute position), stickyfooter

<! Doctype html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Meta name = "Author" content = "Hu Chao">
<Title> super Hu </title>
<Style>
*{
Margin: 0;
Padding: 0;
}
Html, body, # wrap
{
Height: 100%;
}
Body> # wrap
{
Height: auto;
Min-height: 100%;
}
# Main
{
Padding-bottom: 150px;
}/* Must be same height as the footer */
# Footer {
Position: relative;
Margin-top:-150px;/* negative value of footer height */
Height: 150px;
Clear: both;
Border-color: 1px solid red;
Background: red;
}
/* Clear fix */
. Clearfix: after
{Content :".";
Display: block;
Height: 0;
Clear: both;
Visibility: hidden;
}
. Clearfix {display: inline-block;
}
/* Hides from IE-mac */
. Clearfix {height: 1%;/* zoom: 1 */
}

</Style>
</Head>
<Body>
<Div id = "wrap">
<Div id = "main" class = "clearfix">
</Div>
</Div>
<Div id = "footer"> sagsdhgdf
</Div>
</Body>
</Html>
You will find that the height of the footer is reused three times here, which is crucial and the same value must be used for the three heights. The height attribute of wrap <div> extends itself to the size of all the windows. The negative margin increases footer to the position of the padding of main <div>, because the main is already in the wrap, the padding of the main is already part of the wrap 100% height. In this way, footer stays at the bottom of the page.

We still need to go to clearfix main <div>.
. Clearfix: after {content :".";
Display: block;
Height: 0;
Clear: both;
Visibility: hidden ;}
. Clearfix {display: inline-block ;}
/* Hides from IE-mac \*/
* Html. clearfix {height: 1% ;}

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.