网页文本溢出
单行文本溢出
.text-ellipsis {
text-overflow:ellipsis;
white-space:nowrap;
overflow:hidden;
}
多行文本溢出
.multiple-text-ellipsis {
display: -webkit-box;
overflow : hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
jQuery实现文本溢出
function ellipsis(element, contentBox) {
$(element).each(function(i){
var divH = $(this).height();
var $content = $(contentBox, $(this)).eq(0);
while ($content.outerHeight() > divH) {
$content.text($content.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."));
};
});
}
版权声明:本文为李维亮博主的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://www.liweiliang.com/716.html
- 上一篇: 打印常识:A4纸张在显示器上应该要多少像素?
- 下一篇: 让typecho的首页只显示摘要
评论已关闭