Reputation: 54832
Is there the possibility to cut off a word that runs out of a containing box (like a div or paragraph) with CSS3? The white-space: nowrap;
property does not work for me because my text is written in multiple lines and white-space: nowrap;
makes a one-liner out of my text.
Here is a screenshot of my problem:
Upvotes: 0
Views: 870
Reputation: 7154
JS:
max_length = 20;
my_full_text = "My long long text aksjdhfka jshdf kjahds fasdf";
if(my_full_text.length >= max_length){
trimmed_text = my_full_text.substring(0, max_length);
}else{
trimmed_text = my_full_text;
}
alert(trimmed_text)
Where 20
is the max length you want the text to be.
Upvotes: 1