How to limit the number of lines in a text with Javascript/jQuery?

Asked

Viewed 110 times

-2

I want to limit the amount of characters in a paragraph to up to two lines, and not necessarily in an absolute amount of characters, since the amount in each line can vary as the width of the element changes... Is there any way to do this with Javascript/jQuery?

1 answer

0


With responsive width has no way, because as you said yourself: "the number of characters in each line changes according to the width".

What you can do is set fixed width for the element that is the paragraph and then set the maximum of characters, and when it is other widths that must be smaller or greater "that", you can use Media Querie, in this case via javascript, and in the same if(width < X){} you also change the character limits of the element.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.