标签:css wrap 标签 webkit 使用 ... jquery config hub
1行:
white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
ps*:一定要指定容器的宽度,不然的话是没有用的。
多行:
方法一:只支持-webkit内核
<p style="
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
">
方法二:
p {
position:relative;
line-height:1.4em;
/* 3 times the line-height to show 3 lines */
height:4.2em;
overflow:hidden;
}
p::after {
content:"...";
font-weight:bold;
position:absolute;
bottom:0;
right:0;
padding:0 20px 1px 45px;
background:url(http://css88.b0.upaiyun.com/css88/2014/09/ellipsis_bg.png) repeat-y;
}
这里注意几点:
line-height的3倍;content内容,所以要兼容IE6-7可以是在内容中加入一个标签,比如用<span class="line-clamp">...</span>去模拟;::after替换成:after;
js方案:
下载及文档地址:https://github.com/josephschmitt/Clamp.js
使用也非常简单:
var module = document.getElementById("clamp-this-module");
$clamp(module, {clamp: 3});
$(document).ready(function() {
$("#wrapper").dotdotdot({
// configuration goes here
});
});
下载及详细文档地址:https://github.com/BeSite/jQuery.dotdotdot或http://dotdotdot.frebsite.nl/
标签:css wrap 标签 webkit 使用 ... jquery config hub
原文地址:http://www.cnblogs.com/ghfjj/p/6635954.html