When there is less content, the footer of the page always appears at the bottom, not fixed.

Source: Internet
Author: User

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).

    1. * {

    2. margin:0;

    3. }

    4. HTML, Body {

    5. height:100%;

    6. }

    7. . wrapper {

    8. min-height:100%;

    9. Height:auto!important;

    10. height:100%;

    11. Margin:0 Auto-4em;

    12. }

    13. . footer,. Push {

    14. Height:4em;

    15. }

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.

  1. <link rel= "stylesheet" href= "layout.css" .../>

  2. <body>

  3. <div class= "wrapper" >

  4. <p>your website Content here.</p>

  5. <div class= "Push" ></div>

  6. </div>

  7. <div class= "Footer" >

  8. <p>copyright (c) 2008</p>

  9. </div>

  10. </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.

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.