She*_*ali 2 items alignment navbar tailwind-css
<div class="flex md:flex md:flex-grow flex-row-reverse space-x-1">
<a href="" class="py-4 px-2 text-teal-500 border-b-4 border-teal-300 font-semibold">Home</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">Services</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">About</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">Contact Us</a>
</div>
Run Code Online (Sandbox Code Playgroud)
需要做出哪些改变?
要将项目向右对齐,您需要通过justify-end在 Flex 容器内部使用来将 Flex 项目对齐到末尾。
flex-row您还可以通过更改为将导航栏项目与右侧对齐flex-row-reverse。这样,您就可以获得商品顺序的两种变体。
代码:
<div class="flex md:flex md:flex-grow flex-row justify-end space-x-1">
<a href="" class="py-4 px-2 text-teal-500 border-b-4 border-teal-300 font-semibold">Home</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">Services</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">About</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">Contact Us</a>
</div>
<!-- or -->
<div class="flex md:flex md:flex-grow flex-row-reverse space-x-1">
<a href="" class="py-4 px-2 text-teal-500 border-b-4 border-teal-300 font-semibold">Home</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">Services</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">About</a>
<a href="" class="py-4 px-2 text-gray-500 font-semibold hover:text-teal-300 transition duration-300">Contact Us</a>
</div>
Run Code Online (Sandbox Code Playgroud)
Tailwind-play: justify-end,flex-row-reverse。
| 归档时间: |
|
| 查看次数: |
18626 次 |
| 最近记录: |