Search code examples
htmlcssjspsticky-footer

Footer doesn't stick to bottom


i am working on struts2 application.when i am dealing with jsp pages one problem is occurred, when page contents are less footer float below the contents, this will look very bad.but when contents are more than page then it automatically float to the bottom.this is ok for me. Any help will be appreciated...

the code used for footer in css is...

#footer {
    height:41px;
    background:url(../images/main-bg.png) repeat-x;
    width: 100%;
}

Solution

  • For a sticky footer (always on the bottom of the page, no matter the height of the page), use position: fixed;

       #footer {
         height:41px;
         background:url(../images/main-bg.png) repeat-x;
         position: fixed;
         bottom: 0;
         width: 100%;
       }