CSS/Tailwind: 为什么 justify-between 将元素发送到底部而不是 content-between?

CSS/Tailwind: Why does justify-between send element to bottom instead of content-between?

社区,

我有一个简短的问题。我使用的是当前版本的 Tailwind CSS.

我的目标是将按钮 (corpus delicti) 发送到父级 div 的底部。我一直在使用 content-between 但这没有用。 所以我只是为了好玩而尝试 justify-between 并且按钮元素被发送到父元素的底部 div。我不明白。 这是为什么?

在 CSS 文档中指出“

...The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container [...]."

这里是 CSS 代码:

<div class="flex flex-col h-4/5 px-5 items-center justify-center space-x-0 md:flex-row md:space-x-24">


    <div id="parent-div" class="flex flex-col justify-between p-5 w-96 h-96 bg-red-400 ">

      <div class="flex flex-col">
        <h1 class="text-3xl font-bold">foo</h1>
        <p class="text-red-900">bar</p>
        <p class="text-red-900">hoo</p>
      </div>

      <div class="flex flex-row justify-end">
        <button class="w-32 flex flex-row justify-center bg-white rounded-lg shadow-xl">corpus delicti</button>
      </div>

    </div>
    
    <div class="w-96 h-96 bg-yellow-400 flex items-center justify-center md:justify-start">      
      <img class="object-contain" src="../static/pics/gif.gif">
    </div>


</div>

很高兴得到答案,因为这种行为完全摧毁了我对 CSS 来之不易的信任。

提前致谢!

删除 #parent-div 上的 flex-col 并在您的按钮上使用 h-fit (height: fit-content;)。

here

<div class="flex flex-col h-4/5 px-5 items-center justify-center space-x-0 md:flex-row md:space-x-24">


  <div id="parent-div" class="flex justify-between p-5 w-96 h-96 bg-red-400 ">

    <div class="flex flex-col">
      <h1 class="text-3xl font-bold">foo</h1>
      <p class="text-red-900">bar</p>
      <p class="text-red-900">hoo</p>
    </div>

    <div class="flex justify-end">
      <button class="w-32 flex h-fit flex-row justify-center bg-white rounded-lg shadow-xl">corpus delicti</button>
    </div>

  </div>

  <div class="w-96 h-96 bg-yellow-400 flex items-center justify-center md:justify-start">
    <img class="object-contain" src="../static/pics/gif.gif">
  </div>


</div>