Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is as close as I can get without HTML tables:

  <html>
  <head>
  <title>Testing making a footer with CSS</title>
  </head>
  <body>
  
  <div id="divpage">
  <div id="divcontent" style="overflow: auto; height: 60%;">
  This is the content area.
  </div>
  <div id="divfooter" style="overflow: auto; height: 30%;">
  This is the footer.
  </div>
  </div>
  
  </body>
  </html>


I usually go with the footer height 50px, content min-height 100%, bottom-margin -50px. Generally works, but still has some edge cases that can throw it for a loop.

Whereas what I instinctively want to do is something more like a conditional absolute positioning. If the content fits above the fold, then have the footer absolute at bottom:0. Else, have it relative to the content div. It can be done in JS of course, but I feel it should be a lot easier to do in CSS.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: