Home  >  Article  >  Web Front-end  >  Ellipses are automatically generated when the text exceeds the specified number of lines.

Ellipses are automatically generated when the text exceeds the specified number of lines.

php中世界最好的语言
php中世界最好的语言Original
2018-04-28 10:29:241257browse

This time I will bring you the automatic generation of ellipses when the text exceeds the specified number of lines, and the automatic generation of ellipses when the text exceeds the specified number of lines. What are the precautions?. Here is a practical case, let's take a look.




  
  www.jb51.net jQuery自动添加省略号
  
  
  

  

    

      You probably can't do it (currently?) without a fixed-width font like Courier. With       a fixed-width font every letter occupies the same horizontal space, so you could       probably count the letters and multiply the result with the current font size in       ems or exs. Then you would just have to test how many letters fit on one line, and       then break it up.

  

Operation effect:

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to verify the correct email address in JS

How to pass array parameters in js

The above is the detailed content of Ellipses are automatically generated when the text exceeds the specified number of lines.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn