【发布时间】:2012-08-03 19:49:50
【问题描述】:
我找到了this question here on SO,解决方法很简单:
jsfiddle:http://jsfiddle.net/Y5vpb/
html:
<span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen look</span>
css:
span{
display:inline-block;
width:180px;
white-space: nowrap;
overflow:hidden !important;
text-overflow: ellipsis;
}
它按预期工作,打印:Lorem Ipsum is simply du...
现在,我想做同样的事情,但一直失败,在以下示例中创建:
jsfiddle:http://jsfiddle.net/9HRQq/
html:
<div class="textContainer">
<img src="#" class="image" alt="the_image">
<span class="text">"The quick brown fox jumps over the lazy dog" is an english-language pangram, that is, a phrase that contains all of the letters of the English alphabet. It has been used to test typewriters and computer keyboards, and in other applications involving all of the letters in the English alphabet. Owing to its brevity and coherence, it has become widely known.</span>
</div>
css:
.textContainer{
width: 430px;
float: left;
margin-top: 10px;
border: 1px solid black;
}
.text {
font-size: 24px;
line-height: 24px;
font-weight: bold;
color: #047F04;
display: block;
white-space: normal;
overflow: hidden !important;
text-overflow: ellipsis;
height: 99px;
}
.image {
float: right;
position: absolute;
top: 85px;
right: 10px;
width: 108px;
height: 42px;
}
您能告诉我如何在我的示例中将... 放在字符串的末尾吗?
【问题讨论】:
-
你不应该需要
!important。 (如果您确实需要它,那么您的样式表中的其他地方可能有问题)