css方式(建议使用)
用css方式来实现截取字符串并补充省略号:

那么我们来了解一下这几个css属性,为何能实现这种效果:
1. white-space
如何处理元素内的空白

2. word-break
自动换行的处理方法

3. overflow
当内容溢出元素框时发生的事情

4.text-overflow(本次功能实现的最重要部分)
当文本溢出包含元素时发生的事情

js方式
这种方式应用较少,直接上代码:

版权印为您的作品印上版权47110210
css方式(建议使用)
用css方式来实现截取字符串并补充省略号:
那么我们来了解一下这几个css属性,为何能实现这种效果:
1. white-space
如何处理元素内的空白
2. word-break
自动换行的处理方法
3. overflow
当内容溢出元素框时发生的事情
4.text-overflow(本次功能实现的最重要部分)
当文本溢出包含元素时发生的事情
js方式
这种方式应用较少,直接上代码:
版权印为您的作品印上版权47110210
本文标题:截取字符串并补充省略号的两种方法
本文链接:https://www.haomeiwen.com/subject/nvihnttx.html
网友评论