I was looking other answers, and they are all based on something like this:
.text-limit{
line-height:20px;
height: 20 * n. lines;
overflow: hidden;
}
However what i want i something like Youtube
does, so if the text is longer than 2 lines, truncate it and add ...
at the end.
However, i was able to do it using Node
on my terminal, because every char on the terminal has the same width, but on browser it's not true, so i was wondering if there was already something that can help me doing this.
Code i was using:
const nLines = ...;
const lineWidth = ...;
const charWidth = ...;
let text = "...";
text = text.substring(0, nLines * Math.floor(lineWidth / charWidth) - 3) + "..."
console.log(text);