bootstrap-table 列寬問題解決


        

<th style="width:120px" data-field="Cel1"><div class="th-inner ">列名</div><div class="fht-cell"></div></th>

  以上為BootStrap-Table 生成的列   我發現這個widtn 不生效 嘗試在  設置樣式 .th-inner  的寬度 成功了  於是 給出以下解決方案

首先創建一個樣式

.W120 .th-inner {
    width:120px !important;
} 
.W80 .th-inner {
    width:80px !important;
} 
.W60 .th-inner {
    width:60px !important;
} 

.W150 .th-inner {
    width:150px !important;
} 

  然后在 指定 columns  參數時 給要指定長度的列添加class 

 {
      class: 'W120',
       field: 'OPERATETIME',
       title: '盤點時間'
                    }

  

<table id="table"></table>
<style>
.W120 .th-inner {
    width:120px !important;
} 
.W80 .th-inner {
    width:80px !important;
} 
.W60 .th-inner {
    width:60px !important;
} 

.W150 .th-inner {
    width:150px !important;
} 

</style>
<script>
$('#table').bootstrapTable({
    columns: [{
        field: 'id',
        class:'W60'
        title: 'Item ID'
    }, {
        field: 'name',
        class:'W80'
        title: 'Item Name'
    }, {
        field: 'price',
        class:'W120'
        title: 'Item Price'
    }],
    data: [{
        id: 1,
        name: 'Item 1',
        price: '$1'
    }, {
        id: 2,
        name: 'Item 2',
        price: '$2'
    }]
});    
</script>

  

 
       


免責聲明!

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



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