在阅读更多之前先切断文字 [英] Cut off text before read more

查看:83
本文介绍了在阅读更多之前先切断文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大部分时间适合的文本,但有时它不适合。没有办法确定有多少字符/单词/段落适合在div,所以我不能这样裁减。



div有固定的高度和宽度,所以我们可以做点什么吗?或者你有什么建议如何获得div中的一切,正确的方式?

解决方案

如果文本不适合,你可以使用css elipses,使它看起来有点干净。也许把文本放在一个隐藏的元素,并测量高度,看看是否需要包含一个(更多)链接。



请参阅 http://mattsnider.com/css/css-string-truncation-with-ellipsis/


I have texts that most of the time fit in a div, but sometimes it doesn't fit. There is no way to determine how many characters/words/paragraphs fit in the div, so I can't cut it off that way.

The div had a fixed height and width, so can we do something with that? Or do you have any suggestion how to get everything in the div, the correct way?

解决方案

If the text isnt going to fit, you could use a css elipses to make it look a bit cleaner. Perhaps place the text in a hidden element and measure the height to see if you need to include a (more) link.

See http://mattsnider.com/css/css-string-truncation-with-ellipsis/

这篇关于在阅读更多之前先切断文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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