gpt4 book ai didi

css - 如何选择某物内的任何地方?

转载 作者:行者123 更新时间:2023-11-28 01:44:22 25 4
gpt4 key购买 nike

假设有一大群选择器:

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 strong 那样做,但它没有正常工作。在不添加上面列出的任何内容的情况下执行此操作时,一切正常,但它会选择我不需要选择的元素。

<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>

最佳答案

试试看:

.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 属性中的 "

关于css - 如何选择某物内的任何地方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50262071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com