user349072 user349072 - 1 year ago 88
CSS Question

CSS word ellipsis ('...') after one or two lines

I'm trying to create a word-wrap in JavaScript using CSS, and the condition is:

If DIV contains one very long word, such as "asdasfljashglajksgkjasghklajsghl", I want to display:


If DIV contains a long sentence, such as "if i had a dime for everytime i was told i can't", I want to display:

|if i had a dime for|
|everytime i was... |

I work with HTML, CSS, JavaScript. I can't use jQuery.

Please let me know if it's possible.

Answer Source

For this you can use text-overflow: ellipsis; property. Write like this

white-space: nowrap;
text-overflow: ellipsis;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download