zoukankan      html  css  js  c++  java
  • 文本换行

    1.单行文本超出,显示省略号

    div{
    display:block;
    100px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis
    }

    2.自动换行

    div{ 
    word-wrap: break-word; 
    word-break: normal; 
    }

    3.强制英文单词断行

    div{
    word-break:break-all;
    }

    4.强制不换行

    div{
    white-space:nowrap;
    }

    二、多行文本超出,显示省略号

    1、如果用BUI框架HForm的store,写法如下:

    {title : '标题',elCls : 'center',dataIndex : 'title',180,
        renderer:function(value){
          if(value.length > 20){
            var newValue=value.substring(0, 19) +'...';
            return newValue;
          }
          return value;
    
    }}

    2、如果用KISSY点击事件,写法如下:

    S.one('.row').each(function(){
    var maxwidth=20;
    if(S.one(this).text().length>maxwidth){
    S.one(this).text(S.one(this).text().substring(0,maxwidth));
    S.one(this).html(S.one(this).html()+'...');
    }
    });

    3、如果用Jquery点击事件,写法如下:

    $( '.row ').each(function(){
    var maxwidth=20;
    if($ (this).text().length>maxwidth){
    $ (this).text($ (this).text().substring(0,maxwidth));
    $ (this).html($ (this).html()+'...');
    }
    });

    4、 如果用javascript,写法如下:

    var $strtext = $('.strtext');
    for(var i = 0; i < $strtext.length; i++){
        var strtextText = $strtext.eq(i).text();
        if(strtextText.length > 51){
            $strtext.eq(i).text(strtextText.substring(0, 51) + '...');
        }
    }
  • 相关阅读:
    Jquery easyui中的有效性检查
    当执行批量删除时
    nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1044 > 1024
    java的四种取整方法
    springmvc乱码解决
    跨域
    垂直居中
    js判断数组
    安装 node-sass 的正确姿势
    js判断qq浏览器
  • 原文地址:https://www.cnblogs.com/gwzzllw/p/6046158.html
Copyright © 2011-2022 走看看