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

WBOY
Release: 2016-06-24 12:24:59
Original
1121 people have browsed it

很长的英文, 想在

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

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>
Copy after login

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

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

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


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

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!