i have a css as below
div.b {
white-space: nowrap;
width: 50px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
line-height: 16px;
white-space: normal;
}
with the text
no-webkit-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
then text-overflow: ellipsis will not work as expected if using display: -webkit-box;
it works perfect other if the text doesn’t include symbol like !!!!!!!!!!!!!!!!!!!!!!!
or remove display: -webkit-box;
. but i want to keep display: -webkit-box;
because i need display 2 lines which is required display: -webkit-box;
any solution will be appreciated!
here is code in the jsfiddle.
https://jsfiddle.net/thanhtungka91/gvbchao1/
3
Answers
add this style to your code.
line-break: anywhere;
Solution for your issue is pretty simple and straight forward add
word-break: break-word
to.b
that’s it.This configuration ensures that the text will be correctly clamped to two lines with an ellipsis, even when it includes special characters like exclamation marks.