Shahin
Shahin

Reputation: 12843

How to position div at the bottom of a page

How can I set position of a <div> to the bottom of page with either CSS or jQuery?

Upvotes: 11

Views: 47470

Answers (6)

Gilberto Giro
Gilberto Giro

Reputation: 1

I think you can do this:

    html{
      min-height:100%;
      position:relative;
      background-color:red;
    }
    .footer{
      bottom:0;
      position:absolute;
      background-color:blue;
    }
<html>
  <body>
    <div class='footer'>
    <h1>I am Footer</h1>
    </div>
    </body>
  </html>

Upvotes: 0

Shrinivas Naik
Shrinivas Naik

Reputation: 311

The combination position:fixed; with bottom:0; works for me.

Upvotes: 1

Stefan Haberl
Stefan Haberl

Reputation: 10539

This has been answered already, but to give a little bit more context for non CSS-experts:

Given the HTML

<html>
  <body>
    <p>Some content</p>
    <div class="footer">down there</div>
  </body>
</html>

then the following css

div.footer {
  position: absolute;
  bottom: 0;
  right: 0;
}

will position the text at the lower right corner of your viewport (browser window). Scrolling will move the footer text.

If you use

div.footer {
  position: fixed;
  bottom: 0;
  right: 0;
}

on the other hand, the footer will stay at the bottom of your viewport, even if you scroll. The same technique can be used with top: 0 and left: 0 btw, to position an element at the top left corner.

Upvotes: 1

Hussein
Hussein

Reputation: 42818

Use position:absolute and bottom:0

Check working example. http://jsfiddle.net/gyExR/

Upvotes: 11

fabrik
fabrik

Reputation: 14365

You can use position:absolute;bottom:0; if that's all you want.

Upvotes: 6

lmondria
lmondria

Reputation: 244

in css: position:absolute or position:fixed

Upvotes: 2

Related Questions