>  기사  >  웹 프론트엔드  >  长字串变省略的css_html/css_WEB-ITnose

长字串变省略的css_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 12:24:591127검색

很长的英文, 想在

中显示两行后出现省略,如:

Ford acolytes hauled the paper before the Ontario Press Council, charging that the Star’s use of unnamed sources was unethical and that the media’s focus on the issue was detrimental to the democratic life of the city.

在td里变成
Ford acolytes hauled the paper
before the Ontario Press Council...

如何能用CSS简单搞掂?

回复讨论(解决方案)

用javascript截字符串试试  
css里倒是有个类似的功能  不过好像在td里不怎么凑效

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

你这个css只能实现显示一行并省略, 我现在是就是用js插入
去实现, 但限制很大, 当div等宽度变了就麻烦了

  <style type="text/css">    td    {      font-size: 12px;      overflow: hidden;      padding-left: 5px;      text-align: left;      text-overflow: ellipsis;      white-space: nowrap;      word-break: break-all;    }    table    {      table-layout: fixed;    }  </style>

版主大大, 你这个也只是实现显示一行并省略

版主大大, 你这个也只是实现显示一行并省略

你想显示多行并省略?字符会自动换行的啊


自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行

一般都是一行才显示省略号的,如果多行,你可以参考这个插件
http://tpgblog.com/2009/12/21/threedots-the-jquery-ellipsis-plugin/

多谢版主, 这个插件正是我要的功能

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.