How to add background color to rows in bootstrap table
bootstrap table definition code:
$table.bootstrapTable({ showExport: true, height: 540, rowStyle:rowStyle,//通过自定义函数设置行样式 columns: [ { field: 'id', title: '序号', align: 'center', sortable: true }, { field: 'sid', title: '学号', align: 'center' }, ] });
bootstrapTable setting rows Style (background color) function 1: Set the background color of the specified row by calling the bootstrap default style
function rowStyle(row, index) { var classes = ['active', 'success', 'info', 'warning', 'danger']; if (index % 2 === 0 && index / 2 < classes.length) { return { classes: classes[index / 2] }; } return {}; }
bootstrapTable Set row style (background color) Function 2: Call the custom style to set the specified row Font color
function rowStyle(row, index) { var style = {}; style={css:{'color':'#ed5565'}}; return style; }
Related recommendations: "bootstrap tutorial"
The above is the detailed content of How to add background color to rows in bootstrap table. For more information, please follow other related articles on the PHP Chinese website!