我将类添加到单元格中以更改默认的 width、height 等...。现在在操作中,单元格仍然保持默认的内联样式。如果是 width。
如何删除/禁用默认内联样式?!
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>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
如果宽度不起作用,我更喜欢使用最小宽度
.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; }如果类不能访问样式那么你可以使用id,因为id更强大
#custom-width{ // your code }如果你不想使用!important那么你可以通过父标签/ClassName访问
.parent-class .custom-width{ // Your Code }如果不能通过父类访问,那么可以通过id访问。因为id比class更强大
#id .custom-width{ width: 150px; }否则使用 !important 如果父类也不能访问