First, using CSS, refer to a solution abroad:
http://ryanfait.com/resources/footer-stick-to-bottom-of-page/
How to use the CSS Sticky Footer on your website
Add the following lines of CSS to your stylesheet. The negative value for the margin is the same number as the .wrapper height of and .footer .push . The negative margin should always equal to the full height of the footer (including any padding or borders your may add).
* {
margin:0;
}
HTML, Body {
height:100%;
}
. wrapper {
min-height:100%;
Height:auto!important;
height:100%;
Margin:0 Auto-4em;
}
. footer,. Push {
Height:4em;
}
Follow this HTML structure. No content can be outside of the. Wrapper and. Footer div tags unless it's absolutely positioned with CSS. There should also be no content inside the. Push as div it is a hidden element, "pushes" down the footer so it doesn ' t overlap anything.
<link rel= "stylesheet" href= "layout.css" .../>
<body>
<div class= "wrapper" >
<p>your website Content here.</p>
<div class= "Push" ></div>
</div>
<div class= "Footer" >
<p>copyright (c) 2008</p>
</div>
</body>
Second, use JS, refer to this: (I have not verified, see the code should be feasible)
Http://jingyan.baidu.com/article/2fb0ba4054805900f2ec5f9d.html
Footer Suction Bottom effect var _ch = $ ("#content"). Height ();//This is your middle content div's height var _wh = $ (window). height ();//The entire window is//console. Log ("Window's height", _WH, "content ' s height", _ch, "_wh-_ch:", _wh-_ch); if (_WH-_ch > 192) {$ ("#content"). CSS ("Min-height", (_wh-192) + "px"); }//Hope this piece of code is useful to you!
When there is less content, the footer of the page always appears at the bottom, not fixed.