zoukankan      html  css  js  c++  java
  • datatable行内内容太长,有时不自动换行解决方法

    加一个css属性即可

    style = "word-wrap:break-word;"

    js代码:

    "render": function (data, type, full, meta) {
    return '<p style="word-wrap:break-word;">' + data + '</p>'
    }

    但有时word-wrap会失效,原因如下:

      1.word-wrap对行内元素是没有效果的

    
    

         2.一般情况下,元素拥有默认的white-space:normal(自动换行,不换行是white-space:nowrap),可能是元素中设置的white-space是norwrap导致,无法换行。所以需要设置:    

    white-space:normal;
    word-break:break-all;

    在 td 里面 加上 style="word-wrap:break-word;" 自动换行就好了,如果不想换行,可以将超出内容设为隐藏,

    overflow:hidden; 
    white-space:nowrap;

     

    (1)超过宽度和高度文字会自动隐藏

    <div style="100px;height:25px;overflow-x:hidden;overflow-y:hidden;">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>

     

    (2)设置了td的宽度超过长度自动换行

    <td>
    <div style="100px;word-wrap:break-word;" >cvcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</div>
    </td>
     
    当你的才华还撑不起你的野心时
    那你就应该静下心来学习
    当你的能力还驾驭不了你的目标时
    那就应该沉下心来历练
  • 相关阅读:
    2019年9月15日晚间测试-T1
    机房巨佬的随机名称生成器
    初来乍到
    GKurumi记
    GKurumi记
    小P的团战
    什么才算是真正的编程能力?
    java冒泡排序和快速排序
    “转行做程序员”很难?这里有4个重要建议
    Linux文件I/O(一)
  • 原文地址:https://www.cnblogs.com/yang-xiansen/p/10431711.html
Copyright © 2011-2022 走看看