部分代码:
{"render": function(data, type, row) { if(data) { var now = new Date(data*1000); var nowStr = now.format("yyyy-MM-dd hh:mm:ss"); return "<div style=\"min-width:100px;\">"+nowStr+"</div>"; }else return ""; }, "targets": 5 },
在 td 里面 加上 style="word-wrap:break-word;" 自动换行就好了,如果不想换行,可以将超出内容设为隐藏,
overflow:hidden;
white-space:nowrap;
(1)超过宽度和高度文字会自动隐藏
<div style="width:100px;height:25px;overflow-x:hidden;overflow-y:hidden;">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
(2)设置了td的宽度超过长度自动换行
<td><div style="width:100px;word-wrap:break-word;" >aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
</td>