[英]Tabulator remove or disable inline style
我將 class 添加到單元格中以更改默認width
、 height
等...。 現在,單元格仍然保持默認的內聯樣式。 如果width
。
如何remove/disable
默認內聯樣式?!
var tabledata = [ {id:1, name:"Oli Bob", age:"12", col:"red", dob:""}, {id:2, name:"Mary May", age:"1", col:"blue", dob:"14/05/1982"}, {id:3, name:"Christine Lobowski", age:"42", col:"green", dob:"22/05/1982"}, {id:4, name:"Brendon Philips", age:"125", col:"orange", dob:"01/08/1980"}, {id:5, name:"Margret Marmajuke", age:"16", col:"yellow", dob:"31/01/1999"}, ]; var table = new Tabulator("#example-table", { data.tabledata, //assign data to table columns:[ //Define Table Columns {title:"Name", field:"name", cssClass:"custom-width"}, {title:"Name", field:"name"}, {title:"Age", field:"age", hozAlign:"left", formatter:"progress"}, {title:"Favourite Color", field:"col"}, {title:"Date Of Birth", field:"dob", sorter:"date", hozAlign:"center"}, ], });
.custom-width{ width:150px }
<link href="https://unpkg.com/tabulator-tables@5.4.3/dist/css/tabulator.min.css" rel="stylesheet"> <script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.4.3/dist/js/tabulator.min.js"></script> <div id="example-table"></div>
如果寬度不起作用,我更喜歡使用最小寬度
.custom-width{
min-width: 200px;
}
它運行良好,否則您可以檢查以下選項。
如果你想要限制寬度,那么你也可以使用 max-width 和 min-width
.custom-width{
min-width: 200px;
max-width: set max width
}
如果您的風格不適用,那么您可以使用 CSS 屬性
!重要的
.custom-width{
width: 150px !importnat;
}
如果 class 不能訪問樣式那么你可以使用 id,因為 id 更強大
#custom-width{
// your code
}
如果你不想使用 !important 那么你可以使用父標簽/類名訪問
.parent-class .custom-width{
// Your Code
}
如果不是父class訪問,那么你可以通過id訪問。 因為 id 比 class 更強大
#id .custom-width{
width: 150px;
}
否則使用 !important 如果父 class 也不能訪問
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.