Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a CSS footer either sit at the bottom of the browser window or bottom of content

Tags:

css

Duplicate of this question.

I've got an existing site (jacquelinewhite.co.uk), on it there is a footer. Currently this footer always sits underneath the main content. I'm trying to make it float to the bottom of the browser window, or if the content is bigger than the window, stay at the bottom of the content.

Effectively the HTML is structured like this:

<div id="container">
  <div id="top_bar">
  </div>
<div id="header">
</div>
<div id="left_menu">
</div>
<div id="right_content">
</div>
<div class="clear">
</div>
<!-- FOOTER AREA -->
<div id="footer">
</div>
<!-- END FOOTER AREA -->
</div>

I have tried absolute position, bottom 0, which puts the footer at the bottom of the window, but if the content of the window is bigger then the footer covers the content.

How should I fix this?

like image 607
ilivewithian Avatar asked Mar 05 '09 19:03

ilivewithian


People also ask

What position should the footer be in CSS?

The footer is placed at the bottom of the page.

How do I stick footer to the bottom when page content is less?

Quick answer: Add “display:flex; flex-direction:column; min-height:100vh;” to body or appropriate layout body element, then add “flex:1;” to content wrapper element/section.


2 Answers

This one's always worked well for me: CSS Sticky Footer

like image 60
Chad Birch Avatar answered Oct 07 '22 00:10

Chad Birch


Test drive this...

  body {
    margin:0;
    padding:0;
    z-index:0;
  }

  #toolbar {
    background:#ddd;
    border-top:solid 1px #666;
    bottom:0;
    height:15px;
    padding:5px;
    position:fixed;
    width:100%;
    z-index:1000;
  }
like image 36
Josh Stodola Avatar answered Oct 06 '22 23:10

Josh Stodola