Last active
September 2, 2025 15:54
-
-
Save FFKL/9018d68ac764d01817221145a6d09a21 to your computer and use it in GitHub Desktop.
Auto-resizable ellipsis without fixed width ๐ฎ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ellipsis { | |
position: relative; | |
} | |
.ellipsis:before { | |
content: ' '; | |
visibility: hidden; | |
} | |
.ellipsis span { | |
position: absolute; | |
left: 0; | |
right: 0; | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<td> | |
<div class="ellipsis"> | |
<span>Very very long text for this cell</span> | |
</div> | |
</td> |
Thanks, great workaround, works as expected!
Yes very helpful. I made an interactive version here so I could fiddle with it.
As a note to anyone else, the .ellipsis:before
pseudo-element is needed because it prevents the box containing the overflowing text from collapsing vertically. The issue becomes noticeable when you have other text or content after the text with the ellipsis.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome!