I am looking for a way to truncate a <p>
tag to a given number of lines (with a trailing ...
).
Using a number of characters doesn't work since the width of the element depends on device screen width.
I am looking for a way to truncate a <p>
tag to a given number of lines (with a trailing ...
).
Using a number of characters doesn't work since the width of the element depends on device screen width.
You don't need angular. Just CSS. Set a height and a text-overflow property.
something like this:
p{
height: 200px;
text-overflow: ellipsis;
}
You'll have to figure out the number of pixels that corresponds with the number of lines you want. For example, if you want 10 lines to show, and each line has a height of 20px, the height will need to be 200px.
` tag looks like, what did you try?
– AP. Mar 22 '17 at 16:07