I need help with Multi-line Truncated Text. I can’t cut the final word with "…" in text block with randon string number
So this is my solution which cut the end of my block, but without "…"
<ul className="note__tags">
{tags.map((item) => (
<li className="note__tag-item">{item}</li>
))}
</ul>
&__text {
@include manrope-15($size: 15px, $weight: 500, $color: $grey-blue);
width: 270px;
max-height: 192px;
overflow: hidden;
white-space: wrap;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
margin: 0;
position: relative;
}
And i tried somthing like this, but it look’s like strange and not flexible.
&__text {
@include manrope-15($size: 15px, $weight: 500, $color: $grey-blue);
width: 270px;
max-height: 192px;
overflow: hidden;
white-space: wrap;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
margin: 0;
position: relative;
&::after {
content:"...";
position: absolute;
bottom: 0;
right: 40px;
color: black;
}
}
2
Answers
Try this:
You can change the number of lines displayed with
-webkit-line-clamp: <integer [1,∞]>
.Achieve a multi-line truncated text effect with ellipsis at the end, you can use the CSS
-webkit-line-clamp
property along with the-webkit-box
display model.