This layout bug shows up in a lot of UIs. A row has an icon, a long file name and a button. You want the name to end with "..." when space runs out. You add the usual three lines. Nothing happens. The name keeps its full length and shoves the button past the edge of the card.
The setup
<div class = "file-row" > <img class = "icon" src = "pdf.svg" alt = "" > <span class = "name" > quarterly-report-final-version-2-really-final.pdf </span> <button> Share </button> </div>
Enter fullscreen mode
Exit fullscreen mode
.file-row { display : flex ; align-items : center ; gap : 8px ; width : 280px ; }
.name { flex : 1 ; overflow : hidden ; white-space : nowrap ; text-overflow : ellipsis ; }
Enter fullscreen mode
Exit fullscreen mode
Those three lines on .name are right. MDN points out that text-overflow cannot cause an overflow on its own. You pair it with overflow and white-space , and MDN's own example is overflow: hidden plus white-space: nowrap .…