Trying to center the image while having the nav bar set on the right of the page
<nav class="px-6 py-4">
<div class="justify-center flex items-center">
<div>
<img class="flex h-12 " src="https://www.applesfromny.com/wp-content/uploads/2020/06/SnapdragonNEW.png">
</div>
<button class="justify-self-end">
<i class="fa-solid fa-bars fa-xl"></i>
</button>
</div>
</nav>
I have read through the tailwindcss docs, I’m still unable to fix this issue.
2
Answers
Use ml-auto instead. It gives the item margin-left: auto and ensures it stays on the right despite anything you place left of it.
You could consider using a three-column grid layout. Have the left and right columns be equal length by setting their grid column track sizings to
1fr
. This would mean the middle column would be centered. Place the image in this middle column.