Я пытаюсь выбрать абзац только в том случае, если он не находится внутри пользовательского компонента my-comment. вот так:
// Style all elements that are NOT inside my-component
:not(my-component) *{
color: red;
}
Из ответа @Frox мы видим, что мы можем настроить таргетинг на все, кроме контейнера моего компонента
body :not(my-component *) {
color: red
}
Но если мы укажем еще один уровень для каждого p, кроме p внутри моего компонента, он все равно выберет p...
body :not(my-component *) p{
color: red
}
Может ли кто-нибудь объяснить, почему это не работает, или это ошибка, или это просто невозможно?
/* Style all elements that are descendants of body and NOT inside my-component */
body :not(my-component *) p{
color: red;
}
.container {
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 20px;
}
This paragraph is outside the special container → should be RED.
This paragraph is inside the special container → should be black.
Another span-element inside → black
Another outside paragraph → RED
another span outsize my-component
Моя конечная цель — создать правило стиля, исключающее часть страницы, но нацеленное на все остальное.
:not(header) {
my-dropdown-component {}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -component