将
min-width: 0
应用于 <section>
。这会覆盖由于其处于网格布局中而隐式应用于它的 min-width: min-content
。
<script src="https://cdn.tailwindcss.com/3.4.16"></script>
<main class="grid mx-auto mt-20 min-h-screen w-full max-w-2xl gap-16 bg-gray-100 px-4 pt-4 sm:px-6 sm:pt-6 lg:px-8 lg:pt-8">
<section class="mb-20 min-w-0">
<div class="w-full overflow-x-auto">
<div class="flex space-x-4 pb-4">
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
<div class="h-36 w-48 flex-shrink-0 rounded-lg bg-red-300"></div>
</div>
</div>
</section>
</main>