【发布时间】:2020-01-15 03:25:50
【问题描述】:
我正在处理这种情况......
<template>
<slot name="thing"></slot>
<slot name="other"></slot>
</template>
和类似的实现
<custom-element>
<div slot="thing"> Thing 1 </div>
<div slot="thing"> Thing 2 </div>
<div slot="other"> Thing 3 </div>
</custom-element>
如何使用 CSS 查询同时影响事物 1 和事物 2,但排除事物 3?
【问题讨论】:
-
[slot="thing"]{ border: 2px dashed #f00; }Attribute selectors -
那么事情会像
:head[slot="thing"]给定shadow dom吗? -
我不确定 web 组件的实现...我以为您只是在寻找 css-selector...
slot[name="thing"]也许? -
我发现对 Web 组件有用的东西:在 CSS 外部
:defined、[slot=...],以及对于组件内部的 CSS,:host、::slotted()、@ 987654331@. -
对不起,主持人
标签: css web-component custom-component shadow-dom slot