Разбираемся в CSS
-
Anonymous
Можно ли разместить стиль ShadowRoot?
Сообщение
Anonymous »
Я экспериментирую с пользовательскими элементами Vanilla, но разместить тег стиля невозможно:
Код: Выделить всё
class MyElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: "open"});
}
connectedCallback() {
this.shadowRoot.append(document.getElementById('my-element-template').content.cloneNode(true));
}
}
window.customElements.define("my-element", MyElement);
Код: Выделить всё
p { color: red; }
Why am I still red instead of green?
p { color: green; }
Подробнее здесь:
https://stackoverflow.com/questions/790 ... shadowroot
1728169996
Anonymous
Я экспериментирую с пользовательскими элементами Vanilla, но разместить тег стиля невозможно:
[code]class MyElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: "open"});
}
connectedCallback() {
this.shadowRoot.append(document.getElementById('my-element-template').content.cloneNode(true));
}
}
window.customElements.define("my-element", MyElement);[/code]
[code]
p { color: red; }
Why am I still red instead of green?
p { color: green; }
[/code]
Подробнее здесь: [url]https://stackoverflow.com/questions/79058104/is-it-possible-to-slot-the-style-of-a-shadowroot[/url]