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

WBOY
發布: 2016-06-24 12:24:59
原創
1121 人瀏覽過

很长的英文, 想在

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

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/

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

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!