0

Is it possible to apply CSS to an element only when the text overflows?

For example, I'm using text-overflow: ellipsis; to truncate a long line and would like to (for example) colour the div red when text has overflown

As this is a userstyle (Stylish, to be exact) it has to be achievable in CSS

(and for those wondering, I'm actually trying to get the text to marquee on hover. It works so far, but also marquees even if the text hasn't overflown)

Grayda
  • 1,870
  • 2
  • 25
  • 43
  • No, that is not possible with CSS alone. To maybe(!) find another solution, it could be helpful if you would show what you already have implemented. – CBroe Sep 27 '14 at 11:56
  • make a class that has the overflow:hidden property and the other relevant properties you want. Add that class selectively. – Radu Andrei Sep 27 '14 at 13:17

0 Answers0