Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tailwind CSS - Overflowing footer with fixed position

I'm new to Tailwind CSS and have been trying to make a simple portfolio page with available code samples in Tailwind's documentation.

While the container class is wrapping all content on page with some margin, if I set the footer to fixed position, the footer is overflowing to the right. The issue seems to be with the fixed or absolute class as without this class, the footer takes the container's width.

What can I do to make the footer wrap within the container with the fixed class applied? A CSS approach would do but ideally I'm looking for the reason why Tailwind CSS wouldn't wrap the footer to parent's width.

Code and Demo: https://codesandbox.io/s/tailwind-portfolio-s1r1g

Trying to achieve this: Requirement

like image 903
Crazybud Avatar asked Mar 10 '26 11:03

Crazybud


1 Answers

I have updated the HTML for your code and everything works fine. Here is the updated code : Sandbox link

Updates made was - 1. Removed class container mx-auto from body and added as a separate container div. 2. This new div will hold your nav and other contents, except footer.

What was happening earlier - By default footer was aligning to the left from its parent which was body and as the body was aligning to the center it was displayed as if the footer is right aligned.

If you want to do it from your existing code, you can add one line in css -

footer { left: 0}
like image 182
AKNair Avatar answered Mar 13 '26 02:03

AKNair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!