How can I access the actual text that is displayed in a DIV when using CSS style overflow: hidden?

前端 未结 7 754
名媛妹妹
名媛妹妹 2020-12-20 18:43

I have the following content DIV on my page, which displays dynamic text:

It uses the following

7条回答
  •  抹茶落季
    2020-12-20 18:48

    I don't think what you're asking to do is possible with javascript.

    Alternatively, why not truncate the text at a specific character count server-side? You probably won't have the kind of control you want over the size of the div displayed on the page depending on the font you've selected but it should solve your problem.

    Edit:

    Take a look at this to get automatic CSS ellipsis. There are a few caveats and it looks pretty browser-specific but this is another method of doing what you want.

提交回复
热议问题