2017-04-11 75 views
1

我们从后台获取内容,并且只需显示三行。在第三行的末尾,我们需要添加三个点。在第n行末尾添加三个点

我做了什么至今让三条线 -

var height = $(this).find('.sample').outerHeight(); 
var lineHeight = $(this).find('p').css('line-height'); 
$(this).find('.sample').css('max-height',lineHeight*3); 

.sample{overflow: hidden;} 

这里越来越显示三行。但如何添加点?我已经尝试过webkit,但它不适用于ie。

+0

CSS .. ..') –

+0

“*我尝试了webkit *” - 你试过了什么特定的'webkit'?请出示您的“* [mcve] *”代码,以便我们重现您的问题,并为您和未来的访问者提供特定的切实可行的帮助。 –

回答

1

你可以试试这个:

.add-three-dots{display: inline-block; 

    width: 240px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    background: #FFFCD7; 
    padding: 5px; 
    } 


 <span class="add-three-dots">How To Add Three Dots In the End Of String with Css And Jquery?</span> 
0
div{ 
    text-overflow: ellipsis; 
    display: -webkit-box; 
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical; 
    word-wrap:break-word; 
} 

也许这代码不IE浏览器的工作选择后或通过jQuery的append(”