CSS禁用表格列背景色中的输入和表格中选定的行

内奥米

我会提前说 CSS 是我的弱点。我有一个使用以下 ng-repeat 语句创建的 angularJs 表:

 <table id="lineItemsTable"
                           class="table table-bordered table-hover table-list scroll">
                        <thead>
                            <tr>
                                <th>@Labels.itemId</th>
                                <th>@Labels.nickname</th>
                                <th>@Labels.description</th>
                                <th class="text-right">@Labels.quantity</th>
                                <th ng-if="crud.model.adjType>=0">@Labels.location</th>
                                <th ng-if="crud.model.adjType<0">@Labels.cost</th>
                                <th>&nbsp;</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat-start="result in crud.model.lineItems track by $index"
                                ng-form="lineItemForm"
                                ng-click="crud.selectedMatrixIndex=-1;crud.selectedIndex=$index;"
                                ng-class="{selected: $index === crud.selectedIndex}">

因此,我的网格(表格)中的选定行使用此 css 类以蓝色突出显示:

    .table-list > tbody > tr.selected td {
        background: rgba(204, 229, 255, 1);
    }

此外,在同一个表中,我使用以下 HTML 创建了禁用成本:

<td>                                
                                    <input type="number" name="cost" 
                                           ng-if="crud.model.adjType<0"
                                           ng-model="result.unitCost"
                                           data-sm:number-format
                                           data-accuracy="2"
                                           data-sm:number
                                           ng-disabled="true"
                                           ng-class="{'smYellow' : (result.unitCost>0 && result.costOverride === true), 'smOrange': result.unitCost===0 }"
                                           class="form-control form-control-sm text-right">
                                </td>

其中 smYellow 类如下:

.smYellow {
    fill: #faf37e;
    fill-opacity: 0.4;
    stroke: #faf37e;
    stroke-width: 3;
    background-color: rgba(250,243,126, 0.40) !important;
}

我在这里遇到的问题是当行没有突出显示时,我的黄色看起来很好。但是,当该行突出显示时,我会看到绿色(蓝色 + 黄色)。我想知道这个问题是否有 CSS 技巧或一些聪明的解决方案,所以当行突出显示与否(或者,至少,比绿色更黄)时,我的颜色看起来相同。

我会很感激任何想法。

更新。尝试了建议的想法,但仍然看到绿色 - 我做错了什么?

.smOrange {
    fill: #F58025;
    fill-opacity: 0.4;
    stroke: #F58025;
    stroke-width: 3;
    background-color: rgba(245, 128, 37, 0.40) !important;
}

.smYellow {
    fill: #faf37e;
    fill-opacity: 0.4;
    stroke: #faf37e;
    stroke-width: 3;
    background-color: rgba(250,243,126, 0.40) !important;
}

.table-list > tbody > tr.selected td > input.smYellow {
    background-color: rgba(250,243,126, 1);
    fill-opacity: 1;
}
.table-list > tbody > tr.selected td > input.smOrange {
    background-color: rgba(245, 128, 37, 1);
    fill-opacity: 1;
}

Pop-A-Stash

选择行时看到绿色的原因是因为您将输入的背景设置为 40% 不透明度(alpha)并且蓝色背景正在渗出:

    .smYellow {
      background-color: rgba(250,243,126, 0.40);  // R,G,B,alpha
    }

由于蓝色 + 黄色 = 绿色,因此您看到的是绿色。将不透明度(alpha)设置为 100%,无论选择什么,您都应该看到输入的纯黄色:

    .smYellow {
      background-color: rgba(250,243,126, 1);    // R,G,B,alpha
    }

或者,您可以制定另一个更具体的规则,让您在选择行时设置不同的颜色:

    .table-list > tbody > tr.selected td > input.smYellow{
      background-color: rgba(250,243,126, 0.4); // put your new matching color here
    }

这将要求您!importantsmYellow规则中删除该语句

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

设置表格行的背景色

来自分类Dev

使用jQuery的表格行的背景色

来自分类Dev

表格栏的背景色

来自分类Dev

CSS-表格行背景色填充所有填充空间

来自分类Dev

使用CSS3为每三个表格行提供背景色

来自分类Dev

表格行背景色在打印时不显示

来自分类Dev

更改动态生成的表格行背景色

来自分类Dev

更改动态生成的表格行背景色

来自分类Dev

使用特定值设置td的表格行背景色

来自分类Dev

div行和列的背景色

来自分类Dev

更改表格下的UITableViewController背景色

来自分类Dev

通过FindControl更改表格背景色

来自分类Dev

HTML表格行背景色与float属性不一致

来自分类Dev

由于背景色,悬停上的表格列不起作用

来自分类Dev

在选定的退出处更改文本输入的背景色

来自分类Dev

C#在TableLayoutPanel中更改表格单元格的背景色

来自分类Dev

表格中的背景色未显示空白单元格

来自分类Dev

创建循环以更改表格形式Access 2007中的背景色

来自分类Dev

CSS表格中第一行和第一列的每个单元格的背景颜色不同

来自分类Dev

如何赋予表格白色背景色-Bootstrap,Yii

来自分类Dev

如何设置表格视图的编辑附件的背景色?

来自分类Dev

Mailchimp编辑表格单元格背景色

来自分类Dev

设置单击的表格单元格的背景色

来自分类Dev

如何使用Office JS设置表格标题背景色

来自分类Dev

表格背景色给人以彩色边框的错觉

来自分类Dev

如何设置表格视图的编辑附件的背景色?

来自分类Dev

从表格的行和列中查找文本

来自分类Dev

是否可以从单个表格更改所有表格的背景色?

来自分类Dev

如何基于其他单元格值在Google表格中对背景色计数进行计数或相加运算

Related 相关文章

热门标签

归档