Как выбрать где-нибудь внутри чего-то? - PullRequest
0 голосов
/ 10 мая 2018

Скажем, есть большая группа селекторов:

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>

1 Ответ

0 голосов
/ 10 мая 2018

Попробуйте:

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...