I made an image for this question to make it easier to understand.
Is it possible to create an ellipsis on a
Maybe quite late but using SCSS you can declare a function like:
@mixin clamp-text($lines, $line-height) {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: $lines;
line-height: $line-height;
max-height: unquote('#{$line-height*$lines}em');
@-moz-document url-prefix() {
position: relative;
height: unquote('#{$line-height*$lines}em');
&::after {
content: '';
text-align: right;
position: absolute;
bottom: 0;
right: 0;
width: 30%;
height: unquote('#{$line-height}em');
background: linear-gradient(
to right,
rgba(255, 255, 255, 0),
rgba(255, 255, 255, 1) 50%
);
}
}
}
And use it like:
.foo {
@include clamp-text(1, 1.4);
}
Which will truncate the text to one line and knowing that it is 1.4 its line-height. The output expected is chrome to render with ...
at the end and FF with some cool fade at the end
Firefox
Chrome