<div class="flex bg-black h-12 items-center space-x-11">
<nav class="">
<span>
<a
class="text-white text-3xl font-bold hover:text-gray-300 hover:underline"
href="#"
>Corner Hair Salon</a
>
</span>
<span>
<a
class="text-white text-3xl hover:text-gray-300 hover:underline"
href="#"
>Home</a
>
<a
class="text-white text-3xl hover:text-gray-300 hover:underline"
href="#"
>About</a
>
<a
class="text-white text-3xl hover:text-gray-300 hover:underline"
href="#"
>Appointments</a
>
</span>
<span>
<a
class="text-white text-3xl hover:text-gray-300 hover:underline"
href="#"
>Sign-In</a
>
</span>
</nav>
</div>
I’m new to web development, and I’m using tailwind to design my webpage – I want to space apart the elements in my navbar, such that ‘Corner Hair Salon’ is aligned left, ‘Home’-‘Appointments’ is centered, and ‘Sign-In’ is aligned right. I still can’t figure out how to structure my HTML/CSS to get that result – any help is appreciated.
2
Answers
The
justify-between
class on the span.flex element will space out the navbar items evenly.Add following classes to nav
flex justify-between w-full
The nav bar is not getting proper width and because of that flex property is also not satisfying the result. And flex property should be applied to parent element which has immediate children items on which flex needs to be applied.
You can learn more about flexbox from CSS Tricks site.