在阅读更多之前先切断文字 [英] Cut off text before read more
问题描述
我有大部分时间适合的文本,但有时它不适合。没有办法确定有多少字符/单词/段落适合在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屋!