2

How to show a div.bottom of some 100px height at the bottom of the page. If the content height is less than window's height, div.bottom will be shown at the bottom of the window. If the height of the content is greater than window's height it will be shown at the bottom of the page.

Gordon Gustafson
  • 40,133
  • 25
  • 115
  • 157
coure2011
  • 40,286
  • 83
  • 216
  • 349

5 Answers5

2

Do you need something like this?

<div style="position:absolute; bottom:0;">Hi</div>

http://jsbin.com/ayaqo4

Fran Verona
  • 5,438
  • 6
  • 46
  • 85
1

What you're talking about is called a sticky footer, and it can be done with just html and css. The basic idea is to use a wrapper with heights: 100% and a negative margin to move it above the very bottom. Stole the code snippet from here and here:

<body>
    <div class="wrapper">content here!
         <div class="push"></div>
    </div>

    <div class="footer">footer content</div>
</body>

* {

    margin: 0;
  }
  html, body {
    height: 100%;
  }
  .wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */
  }
  .footer, .push {
    height: 142px; /* .push must be the same height as .footer */
  }
Community
  • 1
  • 1
Gordon Gustafson
  • 40,133
  • 25
  • 115
  • 157
1

This is my personal favorite for sticky footers:

http://www.cssstickyfooter.com/

inxilpro
  • 20,094
  • 2
  • 24
  • 28
0

You need to use css,

div.pos_fixed_footer{
    position:fixed;
    bottom:0%;
    right:0px;
    background:transparent url(../img/bg_header.png) repeat scroll center top;  
    width:100%;
    height:40px;
}

and then call in your script like this

<div id="pos_fixed_footer"><?php include "footer.html"; ?></div>
devasia2112
  • 5,844
  • 6
  • 36
  • 56
0

I think you mean a footer that is in the bottom of the window only if the content doesn't overflow the window, otherwise it has to go down on the page.

Just implement the code from here http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page

reese
  • 726
  • 8
  • 12