We're sorry but rendepage doesn't work properly without JavaScript enabled. Please enable it to continue.
如何用 css 或 js 实现多行文本溢出省略效果,考虑兼容性?
千锋教育
CSS 实现方式:
1、单行:
2、多行:
3、兼容:
JS 实现方式:
使用split + 正则表达式将单词与单个文字切割出来存入words
加上 '...'
判断scrollHeight与clientHeight,超出的话就从words中pop一个出来