html - 将样式应用于 div 但不是子级
问题描述
解决方案
The :not
rule refers to the target element. Your rule .total:not(strong)
is translated to apply the styles (color: gray
) to an element with class .total
, which is not a strong
node (the <strong>
tag). Since the .total
node is div
, the rule still applies.
Reset the strong's color to initial or choose a different color:
.total {
color: gray;
}
.total strong {
color: initial;
}
<div class="total">Baloons <strong>$3.75</strong></div>
<div class="total">Pens <strong>$1.99</strong></div>
推荐阅读
- php - 即使没有请求,客人结帐也会创建帐户
- amazon-web-services - Curl 在机器上工作,但不在网络浏览器上
- javascript - 如何在最后将数组的元素组合到一个警告框中
- memory - 在不复制内存的情况下重复 pytorch 张量
- statistics - 这个归一化曲线是什么?常数 ^(常数 ^ 观察指数为 100)
- java - Java 数组与数组
- c - 让 GNU 缩进在 If 语句之后添加新的大括号
- eclipse - 从转到定义中排除 *.pyd 文件(使用 ctrl+单击)
- spring - Spring 测试属性覆盖替换整个数组元素
- excel - 使无框用户窗体透明