#TailwindCSS

How to Make Footer Stay at Bottom of Page with Tailwind CSS

Available for new projects • My templatesRefer them & earn up to $59

Author: Radu

Since my post on making the footer stay at the bottom of the page with Bootstrap was useful to many, I decided to write a similar tutorial, but for Tailwind CSS.

Making the footer stay at the bottom of the page with Tailwind CSS is similar to Boostrap. The only difference is the naming of the classes.

Let’s check it out.

Step 1

Add these Tailwind CSS classes to the <body> tag or whatever wrapper you might be using.

flex flex-col min-h-screen

It should look like this:

<body class="flex flex-col min-h-screen">

Step 2

Add this Tailwind CSS class to the <footer> tag or whatever wrapper you might be using.

mt-auto

It should look like this:

<footer class="mt-auto">

Alternative

As an alternative, you can add the grow utility class to your main content wrapper instead of mt-auto in the footer. The grow class adds flex-grow: 1.

It should look like this:

<body class="flex flex-col min-h-screen">
    <header>...</header>
    <main class="grow">...</main>
    <footer>...</footer>
</body>

If the Design Breaks

This solution works. I never had a problem with it, not in Bootstrap or Tailwind CSS.

But if the design breaks, it might be because you:

  • Have an incompatible or specal type of layout;
  • Have a flaw in the layout.

So, make sure everything’s set properly in your layout.

That’s a Wrap

I hope this post has helped you out.

If you're interested in my web design services or templates, want to collaborate, or just have something to say, feel free to shoot me a message.

About Radu

I've been working online from home for over 11 years, gaining valuable experience and developing a wide range of skills, including web design and development, optimization, and SEO.

More posts