如果它是元素的直接子元素,我必须对我的 Web 组件应用特殊的 CSS 样式<body>
。这是我迄今为止尝试过的:
/* applies even if the component isn't a direct child */
:host(body) {
color: red;
}
/* never applies */
:host(body:host) {
color: red;
}
/* never applies */
:host(body:host > my-component) {
color: red;
}
/* never applies */
:host(body > my-component:host) {
color: red;
}
浏览器:Chrome 稳定版 (32.0.1700.107)、Chrome Canary (34.0.1843.3)。