让我们说一大群选择者:
a,
abbr,
acronym,
address,
applet,
article,
aside,
audio,
b,
big,
blockquote,
body,
canvas,
caption,
center,
cite,
code,
dd,
del,
details,
dfn,
div,
dl,
dt,
em,
embed,
fieldset,
figcaption,
figure,
footer,
form,
h1,
h2,
h3,
h4,
h5,
h6,
header,
hgroup,
html,
i,
iframe,
img,
ins,
kbd,
label,
legend,
li,
mark,
menu,
nav,
object,
ol,
output,
p,
pre,
q,
ruby,
s,
samp,
section,
small,
span,
strike,
strong,
sub,
summary,
sup,
table,
tbody,
td,
tfoot,
th,
thead,
time,
tr,
tt,
u,
ul,
var,
video{
font:inherit;
}
如何让他们在#some_container的任何地方只选择纯元素(没有类)?我尝试像#some_container一样强大,但它没有正常工作。如果不添加上面列出的任何内容,一切正常,但它会选择我不需要选择的元素。
<div id="some_container" class="test">
<a href="https://google.com">Applies here</a>
<div id="another_container">
<strong>Applies here</strong>
<strong class="anything">Does not apply here</strong>
</div>
</div>
<div id="main">
<strong>Does not apply here</strong>
</div>
答案 0 :(得分:0)
尝试使用:
.test strong:not([class]) {
color: red;
}
<div id="some_container" class="test">
<a href="https://google.com">Applies here</a>
<div id="another_container">
<strong>Applies here</strong>
<strong class="anything">Does not apply here</strong>
</div>
</div>
<div id="main">
<strong>Does not apply here</strong>
</div>
另请务必关闭"
属性中的href
。