在tailwind中,我遇到了Flex类的一个非常奇怪的行为。我猜你可以将其转换为CSS,但我想保持在tailwind解决方案中。让我解释一下:
如果您运行以下代码片段,则会发现在第一种情况下,即使我尝试使用break-words
类,该行仍会溢出。但是,使用break-all
类不会发生这种情况,但我不想使用该类,因为它可能会断开单词。
当您输出一些普通文本时,它就会像您预期的那样表现。
这是一个问题吗?还是我太过于苛求完美了?
谢谢!
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<!-- My problem. It should break the line and avoid the overflow-->
<div class="flex bg-gray-200">
<div class="flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">
Short
</div>
<div class="flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 break-words">
asuperultraloooooooooonglineoftexoverhereitfeelslikeitdoesnotendddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
</div>
</div>
<!-- When words are smaller it behaves just fine! -->
<div class="flex bg-gray-200">
<div class="flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2">
Short
</div>
<div class="flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 break-words">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui ad labore ipsam, aut rem quo repellat esse tempore id, quidem
</div>
</div>