Answer the question
In order to leave comments, you need to log in
Is it possible to count the number of lines in a div?
Good evening.
The question is:
Is it possible to count the number of lines in a div ? Even if the characters are not separated in any way.
For example, like this word count. Everything is simple here.
The question is, can I do this with strings? (not separated by explicit hyphens)
ZY .
I think you can do something similar when dividing the height of the container by the height of the row.
Answer the question
In order to leave comments, you need to log in
In addition to dividing the height of the div by the height of the line, I can offer this solution .
The essence is simple - we insert a regular span into a div and count its number of regions through the getClientRects method
Take two numbers 1st is the height of the "Height" property of this div block, and take the height of the text here's an example
.youdivblok{
height: 40px;
font-size: 10px;
}
Take two numbers 1st is the height of the "Height" property of this div , and take the height of the text here's an example.
And lineheit won't break anything?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question