This is the code:
<div class="grid w-full gap-4 grid-cols-8">
<div class="flex w-full flex-col gap-1 justify-center items-center max-w-small cursor-not-allowed"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" stroke="none" class="tabler-icon tabler-icon-file-filled h-10 w-10">
<path d="M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h5z"></path>
<path d="M19 7h-4l-.001 -4.001z"></path>
</svg><span class="overflow-hidden text-ellipsis text-center text-xs">sssssssssssssss</span></div>
<div class="flex w-full flex-col gap-1 justify-center items-center max-w-small cursor-not-allowed"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" stroke="none" class="tabler-icon tabler-icon-file-filled h-10 w-10">
<path d="M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h5z"></path>
<path d="M19 7h-4l-.001 -4.001z"></path>
</svg><span class="overflow-hidden text-ellipsis text-center text-xs">dummy.mib</span></div>
</div>
The text breaks out of the container instead of being collapsed. Why is that, and how to fix it?
4
Answers
try this code
Add the
white-space
,overflow
, andtext-overflow
properties to thespan
. it will ensure that the text will be truncated (with an ellipsis) if it overflows its container.This is because
sssssss...
is a continuous word and does not force a line break by default. In Tailwind you can usebreak-all
to make text break at any position.And it seems you intend to implement text overflow ellipsis. In Tailwind you can just use
line-clamp-*
to achieve this effect directly.DEMO on Tailwind Play.
the easy thing I did was to change the
overflow
to the top div.