bootstrap table設置列寬


第一種:

列表寬度設置前:
在這里插入圖片描述
第一步:設置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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM