Bootstrap table striped:如何更改条形背景色仅适用于1列?(Bootstrap table striped: How do I change the stripe backgro

编程入门 行业动态 更新时间:2024-10-27 06:25:31
Bootstrap table striped:如何更改条形背景色仅适用于1列?(Bootstrap table striped: How do I change the stripe background colour ONLY FOR 1 COLUMN?)

我有类似的问题Bootstrap表条纹:我如何更改条纹背景颜色? 。 但主要的区别是我想只改变一列的颜色交替。 这是我的ng表的副作用,我想改变标题'Srv'的第一列的背景颜色,

<table ng-table="fondiTable_C" class="table table-condensed table-bordered table-striped" template-pagination="app/components/gestioneFondi/pagerTemplate.html"> <tr ng-repeat="fondo in data_C"> <td class="i9fontPre text-center" data-title="'Srv'" header-class="'i9header'">{{::fondo.area}}</td> <td class="i9fontPre text-left" data-title="'Chiave IB'" header-class="'i9header'">{{::fondo | formatChiave}}</td> <td class="i9font text-center" data-title="'Stato Pratica'" header-class="'i9header'">{{::fondo.stato}}</td> <td class="i9font text-center" data-title="'Flag S/V'" header-class="'i9header'">{{::fondo.fvs}}</td> <td class="i9font text-right" data-title="'Fondo bucket&nbsp;1 (EUR)'" header-class="'i9header'">{{::fondo.fnd1 | number:2}}</td> <td class="i9font text-right" data-title="'Fondo bucket&nbsp;2 (EUR)'" header-class="'i9header'">{{::fondo.fnd2 | number:2}}</td> <td class="i9font text-center" data-title="'Bucket'" header-class="'i9header'">{{::fondo.bktDH}}</td> <td class="i9font text-right" data-title="'Fondo IFRS9 (EUR)'" header-class="'i9header'">{{::fondo.fndDH | number:2}}</td> <td class="i9font text-center" data-title="'Rapporto'" header-class="'i9header'">{{::fondo | formatRapporto}}</td> <td class="i9font text-center" data-title="'Cdg'" header-class="'i9header'">{{::fondo.cdg | formatCdg}}</td> <td class="i9font text-center" data-title="'FT'" header-class="'i9header'">{{::fondo.fTec}}</td> </tr> </table>

你可以帮帮我吗? 先谢谢你

I have similar question to Bootstrap table striped: How do I change the stripe background colour?. But the main difference is that I would like to change the alternation of colors only for one column. This is the cose of my ng-table, I would like to change the background colour of the first column with title 'Srv'

<table ng-table="fondiTable_C" class="table table-condensed table-bordered table-striped" template-pagination="app/components/gestioneFondi/pagerTemplate.html"> <tr ng-repeat="fondo in data_C"> <td class="i9fontPre text-center" data-title="'Srv'" header-class="'i9header'">{{::fondo.area}}</td> <td class="i9fontPre text-left" data-title="'Chiave IB'" header-class="'i9header'">{{::fondo | formatChiave}}</td> <td class="i9font text-center" data-title="'Stato Pratica'" header-class="'i9header'">{{::fondo.stato}}</td> <td class="i9font text-center" data-title="'Flag S/V'" header-class="'i9header'">{{::fondo.fvs}}</td> <td class="i9font text-right" data-title="'Fondo bucket&nbsp;1 (EUR)'" header-class="'i9header'">{{::fondo.fnd1 | number:2}}</td> <td class="i9font text-right" data-title="'Fondo bucket&nbsp;2 (EUR)'" header-class="'i9header'">{{::fondo.fnd2 | number:2}}</td> <td class="i9font text-center" data-title="'Bucket'" header-class="'i9header'">{{::fondo.bktDH}}</td> <td class="i9font text-right" data-title="'Fondo IFRS9 (EUR)'" header-class="'i9header'">{{::fondo.fndDH | number:2}}</td> <td class="i9font text-center" data-title="'Rapporto'" header-class="'i9header'">{{::fondo | formatRapporto}}</td> <td class="i9font text-center" data-title="'Cdg'" header-class="'i9header'">{{::fondo.cdg | formatCdg}}</td> <td class="i9font text-center" data-title="'FT'" header-class="'i9header'">{{::fondo.fTec}}</td> </tr> </table>

Could you help me? Thank you in advance

最满意答案

您可以使用ngClass将样式有条件地应用于特定的单元格, ngRepeat会为每一行重新绘制它。

像这样的东西

<tr ng-repeat="unit in data"> <td ng-class="{'highlight': selected==='name'}">{{unit.name}}</td> <td ng-class="{'highlight': selected==='model'}">{{unit.model}}</td> <td ng-class="{'highlight': selected==='price'}">{{unit.price}}</td> </tr>

取决于selected的值, td将由highlight类应用

这是一个演示

You can use ngClass to conditionally apply style to a specific cell, ngRepeat will repaint it for every row.

Something like this

<tr ng-repeat="unit in data"> <td ng-class="{'highlight': selected==='name'}">{{unit.name}}</td> <td ng-class="{'highlight': selected==='model'}">{{unit.model}}</td> <td ng-class="{'highlight': selected==='price'}">{{unit.price}}</td> </tr>

depending on the value of selected, a td will be applied by the highlight class

Here's a demo

更多推荐

本文发布于:2023-08-07 05:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1460839.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条形   适用于   背景色   如何更改   striped

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!