Michael Jones
Michael Jones

Reputation: 2272

Display Content If Text Overflows Div

I was wondering if I could do this with PLAIN CSS! :D Now my question is could I display perhaps 3 dots (...) if a div overflows? What I mean is lets say I have a really long line of text, and it is longer then the div's width. If it was longer then the div's width then the rest of it is hidden, and it displays 3 dots in its' place. Is there anyway that I could do this simply, display content on div overflow?

Upvotes: 0

Views: 38

Answers (1)

enigma
enigma

Reputation: 3491

Yup. Taken from css-tricks:

.truncate {
  width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Fiddle here.

Upvotes: 2

Related Questions