1 | initial version |
Here are the steps to create a genuine sticky header/footer with Tailwindcss that remains fixed at the bottom even when scrolling:
fixed
class to the header/footer element.bottom-0
class to the header/footer element to ensure it sticks to the bottom of the page.z-50
class to ensure the header/footer stays on top of other elements on the page.w-full
class to the header/footer element to ensure it spans the entire width of the viewport.Example code for a sticky footer:
<footer class="fixed bottom-0 z-50 w-full bg-gray-900 p-4">
<p class="text-white text-center">This is a sticky footer</p>
</footer>
Example code for a sticky header:
<header class="fixed top-0 z-50 w-full bg-gray-900 p-4">
<p class="text-white text-center">This is a sticky header</p>
</header>
You can adjust the styles and positioning as per your design needs.