前端 - 如何实现指定多少行后内容未显示完就用省略号...代替?
ringa_lee
ringa_lee 2017-04-17 11:32:50
0
8
538

1)已知文字父级元素p的高度,比如500px;
2)已知字体大小:font-size:28px;
如何算出需要显示多少行?
知道多少行后,如何实现指定这些行后内容未显示完就用省略号...代替?

ringa_lee
ringa_lee

ringa_lee

reply all(8)
PHPzhong
.xxx {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-height: 20px;
  max-height: 60px;
}
伊谢尔伦

Limit the maximum number of displayed lines. If it exceeds the limit, use... instead of `!

洪涛

How many lines is how many lines... It is not difficult to control css with 1 line, but more is unclear

巴扎黑

Portal http://stackoverflow.com/questions/3922739/limit-text-length-to-n-line...

洪涛

There are not many lines, only the height. When the content exceeds the specified height, use js to truncate it~

左手右手慢动作

The number of rows cannot be controlled. Use height instead and estimate your number of rows.

Peter_Zhu

About the overflow of text content, use dots (…) ellipsis to indicate

迷茫

Use jquery plug-in jquery.dotdotdot.js to solve

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template