bootstrap中table给行如何加背景色

发布时间:2020-09-21 10:44:19 作者:小新
来源:亿速云 阅读:387

小编给大家分享一下bootstrap中table给行如何加背景色,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

bootstrap table给行怎么加背景色

bootstrap table定义代码:

$table.bootstrapTable({
    showExport: true,
    height: 540,
    rowStyle:rowStyle,//通过自定义函数设置行样式
    columns: [
        {
            field: 'id',
            title: '序号',
            align: 'center',
            sortable: true
        }, {
            field: 'sid',
            title: '学号',
            align: 'center'
        },
    ]
});

bootstrapTable设置行样式(背景颜色)函数1:通过调用bootstrap默认的样式来设置指定行的背景颜色

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设置行样式(背景颜色)函数2:调用自定义样式设置指定行的字体颜色

function rowStyle(row, index) {
    var style = {};            
    style={css:{'color':'#ed5565'}};               
    return style;
}

看完了这篇文章,相信你对bootstrap中table给行如何加背景色有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. html中怎么给table表单加边框
  2. bootstrap给input加图标的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

bootstrap 景色 strap

上一篇:bootstrap给input加图标的方法

下一篇:python中有main函数吗

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》