Home >Web Front-end >Bootstrap Tutorial >How to add background color to rows in bootstrap table

How to add background color to rows in bootstrap table

藏色散人
藏色散人Original
2019-07-23 11:15:155489browse

How to add background color to rows in bootstrap table

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:{&#39;color&#39;:&#39;#ed5565&#39;}};               
    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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn