<html>
<body>
<style>...
.ellipsis span {...}{
white-space:nowrap;
text-overflow:ellipsis; /**//* for internet explorer */
overflow:hidden;
width:190px;
display:block;
}
html>body .ellipsis {...}{
clear:both;
}
html>body .ellipsis span:after {...}{
content: "...";
}
html>body .ellipsis span {...}{
max-width:180px;
width:auto !important;
float:left;
}
</style>
<div class="ellipsis">
<span>www.aa25.cn—毛毛虫是怎么渡过面前的大河的?答案长成蝴蝶
</span>
</div>
</body>
</html>
<body>
<style>...
.ellipsis span {...}{
white-space:nowrap;
text-overflow:ellipsis; /**//* for internet explorer */
overflow:hidden;
width:190px;
display:block;
}
html>body .ellipsis {...}{
clear:both;
}
html>body .ellipsis span:after {...}{
content: "...";
}
html>body .ellipsis span {...}{
max-width:180px;
width:auto !important;
float:left;
}
</style>
<div class="ellipsis">
<span>www.aa25.cn—毛毛虫是怎么渡过面前的大河的?答案长成蝴蝶
</span>
</div>
</body>
</html>
这个虽然是个好方法,可以不用程序控制了,而且也方便修改,但缺陷是firefox浏览器不支持。
本文介绍了一种使用纯CSS实现文本溢出时显示省略号的方法,该方法适用于固定宽度的元素,并通过设置white-space、text-overflow及overflow属性来实现。然而,此方法在Firefox浏览器中可能无法正常工作。

被折叠的 条评论
为什么被折叠?



