Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
A simple example of how to align a div to the bottom of the page.
I needed to stick an element to the bottom of the page when the window was tall, while still keeping it in the normal flow when there wasn’t enough content to fill the screen.
Here is a very minimal example I made using Tailwind CSS:
<html>
<body class="text-center">
<p>test</p>
<p>© 2022</p>
</body>
</html>

We want the “footer” HTML element to stick to the bottom using Flexbox.
So we first use Flexbox (flex flex-col), we set the minimum height to the screen (min-h-screen).
Then we add flex-grow to the element that precedes the footer so it fills the space:
<html>
<body class="text-center min-h-screen flex flex-col">
<p class="flex-grow">test</p>
<p>© 2022</p>
</body>
</html>
This code generates this result:
