vendredi 28 novembre 2014

Truncate string to words AND box size


Vote count:

0




Is there a way to truncate a string to fit certain box size AND only keep full words?


CSS solution truncates to box size, but breaks words:



.truncate {

width: 250px;

white-space: nowrap;

overflow: hidden;

text-overflow: ellipsis;

}


While php truncate cuts the string to number of characters, but not to box length. Eg a string with many i's will take much less space then a string with many m's.


Is there a way to have best of both worlds?



asked 1 min ago







Truncate string to words AND box size

Aucun commentaire:

Enregistrer un commentaire