隐藏部分文字html,css,javascript [英] hide part of the text html, css, javascript

查看:80
本文介绍了隐藏部分文字html,css,javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何隐藏 div span 中的部分文字?

How to hide part of the text inside div or span ?

我有160个字符的文字,但我只想显示前40个。

I have a text of 160 characters but I would like to display only first 40.

我必须在我的 div span 中有完整的文本,因为我在做javascript搜索。

I have to have the complete text inside my div, span as I do javascript searches.

推荐答案

您需要一些javascript来创建隐藏它们的最后120个字符的范围。有一个CSS属性visibility:hidden,可以应用于span。

You will need some javascript to create a span arround the last 120 characters that hides them. There is a CSS attribute "visibility:hidden" that can be applied to the span.

类似这样的结果应该是结果:

Something like that should be the result:

<div>first 40 chars <span style="visibility:hidden">last 120 chars</span></div>

这篇关于隐藏部分文字html,css,javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆