且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用纯CSS隐藏字符串中的最后一个字符

更新时间:2022-11-16 17:21:39

使用CSS3 文本溢出 .

Use CSS3 text-overflow.

(有关 text-overflow )

在jsfiddle上进行实时演示

CSS:

#txt{
    position:relative;
    padding:7px;
    text-align:justify;
    background:#e7e7e7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

工作于:(最新版本)

  • firefox
  • chrome
  • 歌剧
  • ie(没关系:D)