How to get a sticky footer with CSS only?

<div id="wrapper">
  <main>
    <h1>The content</h1>
    <p>
      /* fill with a looot of text */
    </p>
  </main>
  <footer>
    <p>I am a footer</p>
  </footer>
</div>
#wrapper { 
  display: flex;
  flex-direction: column;
  height: 100vh;
}

main {
  flex: auto;
}

footer {
  flex-shrink: 0;
}
Copy

September 6th, 2019

# Sticky footer with CSS

Add to bookmarks

This will move the footer to the bottom of the page. The content can have a dynamic height.

Tracking with Matomo to improve the UX. See Privacy Policy for more details.