2013-10-23 66 views
0

如果我的文字内有超过一定数量的字符,它会放在...中而不是显示所有字符?以HTML格式显示限制字符

在我的页脚中,如果我的无序列表中有一定数量的字符,它会使显示变得混乱起来。

代码:

<li style="width:25%;padding-left:30px;"> 
    <center> 
    <h4>Title Here</h4> 
    <ul style="padding:0px;margin:0px;"> 
     <li>Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test! Just a test!</li> 
    </ul> 
</center> 
    </li> 

回答

2

使用CSS,你可以做这样的事情:

li { 
    width: 150px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
} 

这会不会让你指定的字符数,但像素的宽度。

请参阅小提琴例如:

+0

谢谢!它的工作:) – user2839430