zoukankan      html  css  js  c++  java
  • 文本溢出、字符串过长截取多余文字并用省略号显示

    1、字符串过长CSS截取多余文字并用省略号显示 

    1 line-height: 30px;
    2 text-align: center;
    3 text-overflow:ellipsis;//让超出的内容用...实现
    4 white-space:nowrap;//禁止换行
    5 overflow:hidden;//超出的隐藏
    6 display: block;
    text-overflow:clip;//修剪文本。
    text-overflow:ellipsis;//显示省略符号来代表被修剪的文本。

    2、td内的文字超出显示省略号

            有时table需要固定高度和行数,在不确定数据长度的情况下,只能使td内的文字超出隐藏,以防止由于文字折行引起的结构错乱;
            注:必须放在父级table上添加table-layout:fixed;/* 固定表格布局 */
     

    3、jQuery截取多余文字并用省略号显式

    1 $(".contents").each(function() {
    2     if ($(this).text().length > 50) {
    3     var str = $(this).text($(this).text().trim().substring(0, 50));//截取50个字符
    4         $(this).text($(this).text() + "…");
    5     }
    6 });

      

    4、jQuery的文本溢出插件

  • 相关阅读:
    【Python爬虫】:爬取干货集中营上的全部美女妹子(翻页处理)
    python进阶之py文件内置属性
    Delphi
    Goland debug 报错:could not launch process: decoding dwarf section info at offset 0x0: too short
    Goland 生成可执行文件
    代理加速配置详解
    关掉所有代码折叠folding
    前端工程化概述(转发)
    Reactjs —— 前端框架切换
    TODO——多线程
  • 原文地址:https://www.cnblogs.com/staven/p/4775253.html
Copyright © 2011-2022 走看看