Moving jQuery inside p

So I have a problem with some jQuery.

Basically, I need to create a function that will separate the paragraph when it becomes too large for the container. Half of them will remain in the current container, and the rest will be reduced to the next.

Basically, I want to go line by line through text, checking its height and all lines above it. Is there a way to cross paragraph lines?

In addition, when resizing, I will be attached to the listener so that when the width is changed, the content remains the same height in each element.

I hope everything made sense!

+4
source share
1 answer

I don’t think you can go through the β€œlines” in the paragraph, because visually it might seem that 10 lines can really be just one wrapped line (without actual line breaks).

You can, for example, set overflow to display in the container and determine when an overflow occurs with height/clientHeight , and then split the text by counting words or the like.

UPDATE:

Here is a demo: http://jsfiddle.net/AQwFM/4/

Obviously, improvements are needed, but you need to get started.

+1
source

Source: https://habr.com/ru/post/1346151/


All Articles