是否可以在开槽元素中选择后代元素?
像这样的例子:
::slotted(div p) {
color: blue;
}
<div><p>test</p><div>
没用
最佳答案
不可以,您只能使用 ::slotted()
选择顶级节点。
::slotted() 里面的选择器只能是compound selector , 所以 div p
不是有效的。
根据 Hayato Ito :
The reason of this restriction is to make a selector style-engine friendly, in terms of performance.
参见 the styling example在 Shadow Dom v1 演示文稿中。
关于css - 在开槽元素中设置后代元素的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48389483/