block may change. I would like the
I have the following structure:
<body> <div id="main-wrapper"> <header> </header> <nav> </nav> <article> </article> <footer> </footer> </div> </body>
I use javascript to dynamically load the content in
block may change. I would like the
Ryan Fait’s Sticky Footer is a simple solution that I’ve used many times in the past.
Basic HTML:
CSS:
Translate this to something similar to what you already got, roughly like this:
HTML:
CSS:
Just don't forget to update the negative numbers on the wrapper margins to match the height of the footer and push div. Good luck!
Ryan Fait's Sticky Footer is very good, but I found it lacked basic structure*.
Flexbox version
If you're lucky enough to use Flexbox without having to support older browsers, sticky footers are really easy, and support for dynamically resizing footers.
The trick to making the footer stick to the bottom using Flexbox is to make other elements in the same container bend vertically. All it requires is a full-height wrapper element with
display: flex
and at least one sibling with aflex
value greater than0
: p> CSS:子>