【问题标题】:Youtube Layout with CSS Grid (Tailwind)使用 CSS Grid (Tailwind) 的 Youtube 布局
【发布时间】:2022-02-16 12:17:04
【问题描述】:

我知道你很忙,你给我的任何时间我都非常重视,将不胜感激。

我正在尝试创建一个类似于 Youtube 的布局,其中包含视频播放器、侧边栏和视频下方的 cmets。我正在尝试使用带有 Tailwind CSS 的网格,但评论部分(3 和 4)并未位于视频播放器(1)下方。这是我想的桌面布局: enter image description here

在移动端的顺序应该是视频,侧边栏,然后是 cmets。

到目前为止,这是我的代码:

<div class="container mx-auto">
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-6">
        <div class="flex justify-center text-6xl border-2 border-gray-300 rounded-xl p-6 bg-gray-100 col-end-auto md:col-span-8" style="height: 200px;">1</div>
        <div class="flex justify-center text-6xl border-2 border-gray-300 rounded-xl p-6 bg-gray-100 col-end-auto md:col-span-4" style="height: 400px;">2</div>
        <div class="flex justify-center text-6xl border-2 border-gray-300 rounded-xl p-6 bg-gray-100 col-end-auto md:col-span-4">3</div>
        <div class="flex justify-center text-6xl border-2 border-gray-300 rounded-xl p-6 bg-gray-100 col-end-auto md:col-span-4">4</div>
    </div>
</div>

我很乐意提供任何帮助。

【问题讨论】:

    标签: css css-grid tailwind-css


    【解决方案1】:

    假设您喜欢移动设备尺寸(sm 及以上)以上的一切工作方式。您可以将订单实用程序类order-1order-2 等添加到您的主要元素中,并添加sm:order-none 到它们,以确保订单仅适用于移动设备。

    这是 Tailwind Play 上的示例https://play.tailwindcss.com/RX1JQHMYgo

    【讨论】:

    • 感谢您的回复,但我认为您不明白,移动尺寸以上不起作用,我想知道如何将 3 和 4 插在 1 框下方,而不是它们如何目前是,低于 1 和 2。
    • 啊,好的,您可能想修改您的问题并澄清您要做什么。目前看起来您的手机出现故障。此外,您的评论对我来说也没有多大意义。考虑添加一张您想要的图片。
    猜你喜欢
    • 1970-01-01
    • 2019-05-15
    • 2018-07-14
    • 1970-01-01
    • 2021-09-17
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    • 2019-08-24
    相关资源
    最近更新 更多