柔性布局子项具有
align-self: stretch
默认情况下,这会使所有子元素拉伸到最高的元素。按钮比
<img>
所以
<img>
在高度上拉伸到与按钮相同的高度,从而产生扭曲。考虑覆盖默认值
自对齐:拉伸
通过应用不同的
align-self
例如
align-self: center
通过
self-center
类别:
tailwind.config = {
theme: {
extend: {
colors: {
deepBlue: 'darkblue',
lightBlue: 'lightblue',
},
},
},
};
<script src="https://cdn.tailwindcss.com/3.3.2"></script>
<nav class="bg-deepBlue">
<div class="relative w-[1080px] mx-auto flex items-center justify-between">
<!-- logo -->
<a href="#" class="cursor-pointer py-7 pr-7">
<img src="https://picsum.photos/125/30" alt="RazorpayLogo" width="125px" height="30px" />
</a>
<ul class="flex gap-x-6">
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Payments</a>
<div class="absolute bottom-0 w-full h-1 bg-lightBlue hidden group-hover:block transition-all duration-200"></div>
</li>
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Banking</a>
<div class="absolute bottom-0 w-full h-1 bg-lightBlue hidden group-hover:block transition-all duration-200"></div>
</li>
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Line of Credit</a>
</li>
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Payroll</a>
</li>
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Resources</a>
<div class="absolute bottom-0 w-full h-1 bg-lightBlue hidden group-hover:block transition-all duration-200"></div>
</li>
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Support</a>
<div class="absolute bottom-0 w-full h-1 bg-lightBlue hidden group-hover:block transition-all duration-200"></div>
</li>
<li class="text-white font-mullish py-7 hover:text-lightBlue cursor-pointer transition-all duration-200 relative group">
<a href="#">Pricing</a>
</li>
</ul>
<div class="flex">
<img src="https://picsum.photos/30/20" alt="IndianFlag" width="30px" height="20px" class="self-center" />
<button class="py-3 px-5 font-mullish text-white border-lightBlue border-2 rounded-md">
Log in
</button>
</div>
</div>
</nav>