Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
96
rated 0 times [  99] [ 3]  / answers: 1 / hits: 40667  / 12 Years ago, thu, july 26, 2012, 12:00:00

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:



     |asdasfljashglajk...|


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.


More From » html

 Answers
32

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



white-space: nowrap;
text-overflow: ellipsis;

[#84040] Tuesday, July 24, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stacied

Total Points: 124
Total Questions: 84
Total Answers: 98

Location: Ivory Coast
Member since Sun, Mar 7, 2021
3 Years ago
;