Maison > interface Web > tutoriel HTML > le corps du texte

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

WBOY
Libérer: 2016-06-24 12:24:59
original
1121 Les gens l'ont consulté

很长的英文, 想在

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

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>
Copier après la connexion

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

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

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


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

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

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

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!