【发布时间】:2021-11-08 12:31:36
【问题描述】:
我有这个自定义元素:
<my-custom-form>
#shadow-root
<style>
:host label {
color: red;
}
</style>
<div id="wrapper">
<slot name="form-label"></slot>
...
</div>
</my-custom-form>
现在我使用如下:
<my-custom-form>
<label slot="form-label">Some Label</label>
</my-custom-form>
我希望label 应该设置为红色。但事实并非如此。
<label> 元素不是作为 :host 的直接子元素存在于 light DOM 中吗?
【问题讨论】:
标签: css web-component shadow-dom