我有以下代码:
.reviewed {
background-color: rgba(228, 225, 219, 1);
}
.deleted {
background-color: red;
}
<table>
<tr>
<td>№</td>
<td>Name</td>
</tr>
<tr class="reviewed">
<td>1</td>
<td>Ivan</td>
</tr>
<tr>
<td>2</td>
<td>Andrey</td>
</tr>
</table>
How can I make it so that when both the classes .deleted
and .reviewed
are set on an element the background-color
of .deleted
takes into account background-color
的 .reviewed
?
使用这两个类时,颜色应该比仅使用类 .deleted
更暗。
原文由 Vladimir 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果您使用的是 CSS 预处理器,例如 SASS/LESS,您可以简单地定义两个颜色变量并使用颜色混合函数生成第三种颜色。
SASS 示例:
更少的例子