开槽元素中后代元素的样式 [英] Styling descendent element in slotted element

查看:102
本文介绍了开槽元素中后代元素的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在带槽元素中选择后代元素?

Is it possible to select descendent element in slotted element?

像这样的例子:

::slotted(div p) {
        color: blue;
    }

<div><p>test</p><div>

它不起作用

推荐答案

否,您只能使用::slotted()选择顶级节点.

No, you can only select top-level nodes with ::slotted().

:: slotted()中的选择器只能是 复合选择器 ,因此div p无效.

The selector inside ::slotted() can only be a compound selector, so div p is not a valid one.

根据伊藤雅人:

此限制的原因是,就性能而言,使选择器样式引擎友好.

The reason of this restriction is to make a selector style-engine friendly, in terms of performance.

请参见Shadow Dom v1中的样式示例.演示文稿.

See the styling example in the Shadow Dom v1 presentation.

这篇关于开槽元素中后代元素的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆