jQuery - 添加省略号、断线,但不截断
我想向可滚动 div 中包含的动态文本添加省略号。但是,我不希望文本被截断。我想要添加省略号,然后文本在下一行继续。这是因为 div 一次只显示一行,因此省略号只是让用户知道还有更多内容,他应该单击滚动箭头继续阅读。
最好的方法是什么? ThreeDots http://tpgblog.com/thirddots 似乎是一个非常好的插件,有很多选项,但我只是不知道如何根据我的需要配置它。
感谢您提供的任何帮助。
I would like to add ellipses to dynamic text contained within a scrollable div. However, I don't want the text to be truncated. I want the ellipses to be added, and then the text to continue on the next line. This is because the div only shows one line at a time, so the ellipses just lets the user know that there is more content and he is supposed to click the scroll arrows to continue reading.
What would be the best way to do this? ThreeDots http://tpgblog.com/threedots seems to be a very good plugin with lots of options, but I just don't know how to configure it to my need.
Thank you for any help you can give.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为 DIV 提供高度,然后使用
text-overflow: ellipsis
并防止换行 CSS 方法。举个简单的例子:
当然,总有人来捣乱,这次是火狐。您必须将文件绑定到 CSS。
这比你想象的要容易。只需创建一个新的文本文件,并将其命名为 ellipsis.xml。然后将其粘贴到网络服务器上可以引用的任何位置。
然后在你的 CSS 中,执行以下操作:
这是快速总结,有关更多信息,请查看此人:
http://mattsnider.com/css/css-string-truncation-with-ellipsis/
顺便说一句:如果您认为 Threedots 插件是一个更简单的选择,我建议您选择它。
Provide a height for your DIV, then use the
text-overflow: ellipsis
and prevent line-wrap CSS approach.Here's a simple example:
Of course, there's always somebody making trouble, and this time it's Firefox. You have to bind a file to the CSS.
It's easier than you might think. Just create a new text file, and call it ellipsis.xml. Then stick it anywhere on your web server where you can reference it.
Then in your CSS, do this:
That's the quick run-down, and for more information check out this guy:
http://mattsnider.com/css/css-string-truncation-with-ellipsis/
BTW: If you think the threedots plugin is an easier choice, I say go for it.