

It turns out that there really isn't a clean way to do this. That being said, so what? I mean, can't the spec be adjusted to include text-overflow on flex items? Although you would think it's not a big deal to make this work for flex-items too, there are a number of considerations that need to be taken into account. It turns out text-overflow isn't meant to work on flex items, rather it is meant to work on block items as per the spec. This property specifies rendering when inline content overflows its line box edge in the inline progression direction of its block container element ("the block") that has overflow other than visible. If you look at the spec for, text-overflow you find the definition you see in the quote below I'll try and explain this, but be aware that I'm likely oversimplifying things.Īs I mentioned before, this whole issue is expected behaviour. In case you want to see the end result working, here you can check it out here. Now the text-overflow property applies, and all is good! The Solution in Action The we introduce is a block element that lives inside of the flex item.
#CSS SPAN TEXT OVERFLOW ELLIPSIS CODE#
Item Code that is way too long and shoud use ellipsis

In our case, we need to wrap the text we want to have the ellipsis show up in a block element. The solution is to make sure that we apply the text-overflow property to a block element that lives inside a flex item. It turns out that this is the expected behaviour (see "But Why?" section below). We have everything aligned, but no ellipsis. If their contents exceed the length of the then should display an ellipsis. The goal here is to have all the elements line up, regardless of their contents. This post exists to document both the problem and solution with the hope that it prevents future headaches for other CSS developers. It didn't work as expected, but after some digging, a solution was discovered. He wanted to use the text-overflow: ellipsis on a flexbox item that displayed text, where the ellipsis would show up if the text was too long. Curious? Now I will count 1 2 3 4 5 6 7 8 9.Dave Paquette, a fellow Western Dev, hit a strange CSS snag the other day. Probably it will overflow, right? But maybe, maybe there will be extremely important information that you should not miss in the end. Really? I do not believe you! REALLY! So the ultimate answer is: 42! text-overflow: ellipsis This is sooo long text. Curious? Now I will count 1 2 3 4 5 6 7 8 9. ready ( function () Implicit This is sooo long text.
#CSS SPAN TEXT OVERFLOW ELLIPSIS DOWNLOAD#
Here is the code ( download from github): Left text-overflow test page //on document ready $ ( document ).

Other possibility are various CSS hacks, like this one, or this one, or … They are based on nasty tricks and suffer for many problems. It would allow you to define behavior for both sides of text. Unfortunately it is not possible nowadays, there is only outdated draft of such function done by W3C. But what about text that has more important part on the end? It would be better to show ellipsis on left side, right? That is fine for text has more important part on the beginning. There is CSS text-overflow property that can end text that can visualize by ellipsis (“…”) that text is longer than element size so it overflows element and is hidden. What is worse my cell width depends on client resolution so I cannot trim text on server. In that case client needs to see end of that text because it contains more important data. Today I needed to put one line of possibly long text into table.
