如何去掉 tailwind css 中的水平滚动条?

How remove the horizontal scroll bar in tailwind css?

所以我从他们在 YouTube 上的视频中试用了 tailwindCSS v3 中的新快照功能,但是当我在我的本地机器上实现它时,它在下方显示了一个水平条,如 第一张图片. 但是在视频中没有单杠。 下面附上图片但我写了与视频相同的代码。

视频参考 : https://youtu.be/mSC6GwizOag?t=630

<div class="relative mt-32">
    <h1 class="text-5xl font-extrabold tracking-tight text-center underline capitalize decoration-emerald-400">Get away this winter</h1>
    <ul class="mt-10 pb-8 px-[50vw] w-full flex gap-8 snap-x overflow-x-auto self-center">

        <li class="snap-center">
            <div class="relative flex-shrink-0 max-w-[95vw] overflow-hidden rounded-3xl">
                <img src="https://images.unsplash.com/photo-1542144612-1b3641ec3459?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8NHx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60" alt="" class="absolute inset-0 object-cover object-bottom w-full h-full " />
                <div class="absolute inset-0 w-full h-full bg-gradient-to-br from-black/75"></div>

                <div class=" relative h-96 w-[768px] p-12 flex flex-col justify-between items-start">
                    <div>
                        <p class="font-medium text-stone-50">Destination</p>
                        <h2 class="w-2/3 mt-3 text-3xl font-semibold tracking-tight text-white">amit deka</h2>
                    </div>

                    <a href="#" class="px-4 py-3 text-sm font-medium bg-white rounded-lg text-slate-900"> browse</a>
                </div>
            </div>
        </li>

        <li></li>*4 times
    </ul>
</div>

我目前也在试验滚动捕捉功能和一般的 tailwindcss。我通过添加额外的 CSS class 摆脱了滚动条,因为我还没有找到相应的顺风 class.

/* Hide scrollbar for Chrome, Safari and Opera */
.container-snap::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.container-snap {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}

因此,对于您的代码,当您将 .container-snap class 添加到 ul 元素时,滚动条将消失:

<div class="relative mt-32">
<h1 class="text-5xl font-extrabold tracking-tight text-center underline capitalize decoration-emerald-400">Get away this winter</h1>
<ul class="container-snap mt-10 pb-8 px-[50vw] w-full flex gap-8 snap-x overflow-x-auto self-center">

    <li class="snap-center">
        <div class="relative flex-shrink-0 max-w-[95vw] overflow-hidden rounded-3xl">
            <img src="https://images.unsplash.com/photo-1542144612-1b3641ec3459?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8NHx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60" alt="" class="absolute inset-0 object-cover object-bottom w-full h-full " />
            <div class="absolute inset-0 w-full h-full bg-gradient-to-br from-black/75"></div>

            <div class=" relative h-96 w-[768px] p-12 flex flex-col justify-between items-start">
                <div>
                    <p class="font-medium text-stone-50">Destination</p>
                    <h2 class="w-2/3 mt-3 text-3xl font-semibold tracking-tight text-white">amit deka</h2>
                </div>

                <a href="#" class="px-4 py-3 text-sm font-medium bg-white rounded-lg text-slate-900"> browse</a>
            </div>
        </div>
    </li>

    <li></li>*4 times
</ul>