June 30, 2015 | 1 Minute Read
直接用字符串表示’…’ 或 用HTML实体表示 & hellip; 或 通过伪类 ::after实现
.ellipsis { text-overflow: ellipsis; /* Required for text-overflow to do anything */ white-space: nowrap; overflow: hidden; }
<div class="wrap"> <div class="content"></div> <div class="dot"></div> </div>
.wrap{ overflow: hidden;} .wrap .content{ height: 20px; float: left; margin-right: 15px;} .wrap .dot{ float: right; margin-top: -20px;}
p { overflow : hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
function shorten(text, maxLength) { var ret = text; if (ret.length > maxLength) { ret = ret.substr(0,maxLength-3) + "..."; } return ret; }