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% ;}