CSS 文字溢出:ellipsis在IE上不起效果的解决
<h3>单行文本的溢出显示省略号</h3><div class="jb51code"><pre class="brush:css;">p {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}</pre></div>
<h3>多行文本的溢出显示省略号</h3>
<p>方法一:</p>
<div class="jb51code"><pre class="brush:css;">p {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
}</pre></div>
<p>适用范围:<br />因使用了WebKit的CSS扩展属性,该方法适用于WebKit浏览器及移动端;不兼容IE浏览器。</p>
<p>方法二:</p>
<div class="jb51code"><pre class="brush:css;">p {
position:relative;
line-height:20px;
height:60px;
overflow:hidden;
}
p::after {
content:"...";
position:absolute;
bottom:0;
right:0;
padding-left:45px;
background: -webkit-linear-gradient(left, transparent, #fff 55%);
background: -o-linear-gradient(right, transparent, #fff 55%);
background: -moz-linear-gradient(right, transparent, #fff 55%);
background: linear-gradient(to right, transparent, #fff 55%);
}</pre></div>
<p>局限性:<br />该方法能在谷歌和IE浏览器上出现文字超过就省略的效果,但是不出现…省略号!</p>
頁:
[1]