第一種:
列表寬度設置前:
第一步:設置css的table-layout屬性值為fixed,此時可以自己調整列寬了;再添加word-break:break-all,此時數據可以自動換行。
<style type="text/css">
.table {table-layout:fixed;word-break:break-all;}
</style>
或
<table id="cblx" class="table table-border" style="table-layout:fixed;word-break:break-all;"></table>
table-layout可能值 | 描述 |
---|---|
auto | 默認。列寬度由單元格內容設定。 |
fixed | 列寬由表格寬度和列寬度設定。 |
inherit | 規定應該從父元素繼承 table-layout 屬性的值。 |
第二步:在每一列設置width屬性值
function tab_1_table_init() {
var jsTypeDate={};
jsTypeDate["CTRL-DIV-1044TABLE"]={
"url":"data.json",
"tableId":"cblx20",
"method":"post",
"pageSize":10,
"sort":false,
"page":true,
"Refresh":false,
"id":"CTRL-DIV-1044",
"table_columns":[
{"visible":true,field:"design_unit",title:"設計單位",width:100,align:"center",edit:false},
{"visible":true,field:"item_name",title:"項目名稱",width:200,align:"center",edit:false},
{"visible":true,field:"design_stage",title:"勘察設計階段",align:"center",edit:false,formatter:function (value, row, index, field) {
return '<a href="javascript:void(0)" class="delPro" id="">鏈接</a>';
}},
{"visible":true,"field":"inspection_stage","title":"實施驗收階段","edit":false,formatter:function (value, row, index, field) {
return '<a href="javascript:void(0)" class="delPro" id="">鏈接</a>';
}},
{"visible":true,"field":"final_score","title":"項目綜合考評得分","edit":false}
],
"table_title_text":"",
"loadSuccess":"",
"btn":false};
$('#CTRL-DIV-1044').find(".btn-group").remove();
bootstrap_table(jsTypeDate["CTRL-DIV-1044TABLE"]);
}
設置后:
參考:[https://blog.csdn.net/wang1171405487/article/details/80667530]
第二種
<table id="cblx23" class="resizable-table table-border table-bordered table-hover" width="100%">
<tr>
<th style="vertical-align: middle !important;text-align: center;" width="30%"></th>
</tr>
</table>
參考:https://www.csdn.net/gather_2c/NtzaYgxsMjQxLWJsb2cO0O0O.html?platform=pc&page=2&pageSize=20