How to capture one line of text in a div

后端 未结 4 837
情书的邮戳
情书的邮戳 2021-01-12 14:20

I\'ve looked around at similar SO posts related to this, but none deal with exactly what I am looking for. Say I have some text, I throw it in a div, and add some arbitrary

4条回答
  •  我在风中等你
    2021-01-12 14:32

    Not sure I completely understand your question, but... You will be able to get the div's height right? Divide that by a (CSS-defined) line-height and you should have the number of lines of text.

    You could then check the position of any given character / word by making an invisible div containing part of the original text and performing the abovementioned trick to find its line. Does that help?

提交回复
热议问题