What I need to implement is a text overflow effect, but instead of a "..." truncate which you would get by using text-overflow: ellipsis
it should be a fade out on the last character. The element that should have this is a block of text, something like:
Multiple lines are allowed, if the text has no whitespaces and can't fit in one row, then break-word
will be applied. A maximum of 5 lines are allowed so the fade should occur on the last character when the text can't fit considering the given max-height
. Currently I have the following:
span {
overflow: hidden;
text-align: center;
word-break: break-word;
max-width: 72px;
max-height: 75px; // line height * 5
}
I tried using
-webkit-mask-image: linear-gradient(130deg, #000 80%, transparent);
to achieve an effect which is similar, but this one fades out too many characters.
Is there a way to do this using only CSS?