Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add background colors to rows by bootstrap table

Shulou Source: shulou.com Published: 2022-06-03 10:37:56 11月15日 Update

这篇文章主要为大家展示了"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如何给行加背景色"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

Tags: Background style color content function article learning help code font student number serial number easy to understand more organization knowledge editing industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Xiaomi Redmi Docker vpn