如何使用 TailwindCSS 指定 height: fit-content ?

Ped*_*ipe 23 css reactjs tailwind-css

使用 TailwindCSS 我试图适应<div>它的孩子的高度,a <button>。我的代码如下:

<form className="w-full flex h-96 gap-2 mt-8 flex-wrap">
     <textarea
          role="text-input"
          className="resize-none flex-1"
          placeholder="INPUT"
     />
     <textarea
          role="text-output"
          className="resize-none flex-1"
          placeholder="OUTPUT"
          readOnly
      />
      <div className="w-full flex flex-none"> // This is the troublesome div
          <button>
                Submit!
          </button>
      </div>
</form>
Run Code Online (Sandbox Code Playgroud)

阅读文档并进行谷歌搜索,我似乎找不到一种方法来做到这一点,理想情况下,我想设置一个类,例如h-fit-content(类似这样的东西),但它似乎不存在。

提前致谢!

小智 15

Tailwind 现在已经上课了w-fit


小智 10

Tailwind 现在已经上课了h-fit

  • 请务必解释您的答案和/或使用示例。 (2认同)

Ped*_*ipe 2

我设法通过设置h-full两者<textarea>和设置flex-none我的问题来解决我的问题<div>,产生以下代码:

<form className="w-full flex h-96 gap-2 mt-8 flex-wrap">
     <textarea
          role="text-input"
          className="h-full resize-none flex-1"
          placeholder="INPUT"
     />
     <textarea
          role="text-output"
          className="h-full resize-none flex-1"
          placeholder="OUTPUT"
          readOnly
      />
      <div className="w-full flex flex-none"> // This is the troublesome div
          <button>
                Submit!
          </button>
      </div>
</form>
Run Code Online (Sandbox Code Playgroud)