【问题标题】:Is it possible to implement the effect of overflow:ellipsis with javascript or css?是否可以用javascript或css实现overflow:ellipsis的效果?
【发布时间】:2026-02-18 13:30:02
【问题描述】:

我想在overflow 发生时显示...

但遗憾的是,在 css 中只有 overflow:hidden 接近但不完全符合我的要求。

可以实现吗?

【问题讨论】:

    标签: javascript css


    【解决方案1】:
    text-overflow: ellipsis;
    

    http://www.quirksmode.org/css/textoverflow.htmlhttps://developer.mozilla.org/en/CSS/text-overflow。但是不支持火狐。


    编辑:这里有一个jQuery plugin。安装好后调用

    $(thatElement).ellipsis();
    

    激活样式。见http://jsbin.com/acuti3。除此之外还有一个bunch of other jQuery plugins

    【讨论】:

    • 支持firefox以外的所有其他浏览器?反正我不想放弃firefox..
    【解决方案2】:

    -moz-binding> 火狐
    -o-text-overflow > 歌剧
    text-overflow > ie + webkit (chrome/safari)

    【讨论】:

    最近更新 更多