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

藏色散人
Release: 2019-07-23 11:15:15
Original
5493 people have browsed it

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'
        },
    ]
});
Copy after login

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 {};
}
Copy after login

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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template