单行/多行文本溢出处理
2016-09-09 16:16
239 查看
单行文本溢出
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
多行文本溢出
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
jQuery实现
$(".content").each(function(i){
var $divH = $(this).height();
var $oP = $("p", $(this)).eq(0);
while($oP.outerHeight() > $divH){
$oP.text($oP.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."))
}
});
jQuery截取固定字数
$(".content").each(function() {
if ($(this).text().length > 50) {
var str = $(this).text($(this).text().trim().substring(0, 50));//截取50个字符
$(this).text($(this).text() + "…");
}
});
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
多行文本溢出
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
jQuery实现
$(".content").each(function(i){
var $divH = $(this).height();
var $oP = $("p", $(this)).eq(0);
while($oP.outerHeight() > $divH){
$oP.text($oP.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."))
}
});
jQuery截取固定字数
$(".content").each(function() {
if ($(this).text().length > 50) {
var str = $(this).text($(this).text().trim().substring(0, 50));//截取50个字符
$(this).text($(this).text() + "…");
}
});
相关文章推荐
- 文本单行溢出,多行溢出处理方案【...】
- 如何处理单行文本和多行文本溢出
- 12.css单行和多行文本的溢出处理
- CSS、j's单行、多行文本溢出显示省略号
- CSS实现单行、多行文本溢出显示省略号(…)
- CSS实现单行、多行文本溢出显示省略号(…)
- CSS实现单行、多行文本溢出显示省略号(…)
- 【CSS/JS】如何实现单行/多行文本溢出的省略(...)--老司机绕过坑道的正确姿势
- css 实现单行,多行文本溢出省略号
- css实现单行、多行文本溢出显示省略号
- 关于单行文字,多行文字溢出隐藏时 css jq处理方法 兼容各个浏览器
- CSS实现单行、多行文本溢出显示省略号(…)
- CSS实现单行、多行文本溢出显示省略号(…)
- 单行/多行文本溢出,显示省略号
- 单行文本溢出与多行文本溢出
- 《CSS实现单行、多行文本溢出显示省略号》
- css 单行和多行文本溢出显示省略号
- CSS实现单行、多行文本溢出显示省略号(…)
- CSS实现单行、多行文本溢出显示省略号(…)
- CSS实现单行、多行文本溢出显示省略号