CSS网格填充相同高度的容器,底部的按钮

发布于 2025-02-10 23:45:00 字数 381 浏览 1 评论 0原文

我有以下示例,用尾风CSS编写:

https://play.tai​​l.tail.tail.tailwindcss.com/f9iok/f9iok/f9iok1eok1e0om i i i i i i

i>想要将我的控制按钮放在底部,如果网格容器具有不同的内容尺寸的蓝色“标签”框,因此网格的高度增加了一些容器。但是,当我使用网格时,所有盒子都得到了这个高度。没关系。但是我的控制按钮应该始终位于容器的底部,以便在第二个容器的底部不应远离“启用”和“删除”。

如何实现这一目标?

I have following sample, written in tailwind css:

https://play.tailwindcss.com/f9iOK1e0oM

I want to have my control buttons on the bottom if the grid containers, however, they have different content sizes for the blue "tag" boxes, so the grid gets increased in height by some containers. however, as I am working with grid, all boxes are getting this height then. this is ok. But my control buttons should be always on the bottom of the containers, so that "Enabled" and "Delete" should not be so far away from bottom for the second container.

How to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2025-02-17 23:45:00

您需要将flex-col添加到li元素。 <代码>将添加到第一个儿童div和grow-0 max-h-max到第二个儿童div。

<li class="flex flex-col col-span-1 divide-y divide-gray-200 rounded-lg bg-white shadow">
    <div class=" grow flex w-full flex-col items-start justify-between p-6">
      <div class="flex w-full items-start justify-between space-x-3">
        <h3 class="truncate text-sm font-medium text-gray-900">243rfh83294d-23r8fj2n48r-24fi43bf</h3>
        <span class="inline-block flex-shrink-0 rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800"> running </span>
      </div>
      <p class="mt-1 whitespace-pre-wrap text-xs font-bold text-gray-500">Interval: <span class="font-normal">1234</span></p>
      <p class="mt-1 whitespace-pre-wrap text-xs font-bold text-gray-500">Next run: <span class="font-normal">1234</span></p>
      <p class="mt-1 whitespace-pre-wrap">
        <span class="inline-block flex-shrink-0 rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-800">test 1</span>
      </p>
    </div>
    <div>
      <div class="-mt-px flex shrink-0 grow-0 divide-x divide-gray-200 max-h-max">
        <div class="flex w-0 flex-1">
          <button class="relative -mr-px inline-flex w-0 flex-1 items-center justify-center rounded-bl-lg border border-transparent py-4 text-sm font-medium text-gray-700 hover:text-gray-500">
            <span class="ml-3">Enabled</span>
          </button>
        </div>
        <div class="-ml-px flex w-0 flex-1">
          <button class="group relative inline-flex w-0 flex-1 items-center justify-center rounded-br-lg border border-transparent py-4 text-sm font-medium text-gray-700 transition hover:text-red-500">
            <span class="ml-3">Delete</span>
          </button>
        </div>
      </div>
    </div>
  </li>

https://play.tai​​lwindcss.com/iltmm5glklku

我只在第二张卡中做到了这一点,但是您应该为所有卡做。因此,当内容更改时,按钮行将始终粘在底部并保持所有卡中的相同高度。

希望这会有所帮助。

You need to add flex flex-col to the li element. And grow to the first child div and grow-0 max-h-max to the second child div.

<li class="flex flex-col col-span-1 divide-y divide-gray-200 rounded-lg bg-white shadow">
    <div class=" grow flex w-full flex-col items-start justify-between p-6">
      <div class="flex w-full items-start justify-between space-x-3">
        <h3 class="truncate text-sm font-medium text-gray-900">243rfh83294d-23r8fj2n48r-24fi43bf</h3>
        <span class="inline-block flex-shrink-0 rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800"> running </span>
      </div>
      <p class="mt-1 whitespace-pre-wrap text-xs font-bold text-gray-500">Interval: <span class="font-normal">1234</span></p>
      <p class="mt-1 whitespace-pre-wrap text-xs font-bold text-gray-500">Next run: <span class="font-normal">1234</span></p>
      <p class="mt-1 whitespace-pre-wrap">
        <span class="inline-block flex-shrink-0 rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-800">test 1</span>
      </p>
    </div>
    <div>
      <div class="-mt-px flex shrink-0 grow-0 divide-x divide-gray-200 max-h-max">
        <div class="flex w-0 flex-1">
          <button class="relative -mr-px inline-flex w-0 flex-1 items-center justify-center rounded-bl-lg border border-transparent py-4 text-sm font-medium text-gray-700 hover:text-gray-500">
            <span class="ml-3">Enabled</span>
          </button>
        </div>
        <div class="-ml-px flex w-0 flex-1">
          <button class="group relative inline-flex w-0 flex-1 items-center justify-center rounded-br-lg border border-transparent py-4 text-sm font-medium text-gray-700 transition hover:text-red-500">
            <span class="ml-3">Delete</span>
          </button>
        </div>
      </div>
    </div>
  </li>

https://play.tailwindcss.com/ilTMM5glku

I have done this only for the second card, but you should do it for all cards. So that when the content changes, the button row will always stick to the bottom and keep the same height in all cards.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文