We can put …
in place of '...'. Because it's one character and it's easy to calculate
Last active
August 29, 2015 14:04
-
-
Save mazhar266/4a27978a21797f4e16d2 to your computer and use it in GitHub Desktop.
Limiting text with (...) in CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shorten(text, maxLength) { | |
var ret = text; | |
if (ret.length > maxLength) { | |
ret = ret.substr(0,maxLength-3) + "..."; | |
} | |
return ret; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ellipsis { | |
overflow: hidden; | |
text-overflow: ellipsis; | |
-o-text-overflow: ellipsis; | |
white-space: nowrap; | |
width: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment