[docs] No search results for `How can we apply CSS styles to nested elements inside the slot`
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 30/100
- Issue 类型
- 文档
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- css
调研方向
从链接的 Shadow DOM 文档开始,检查所报告的 slot 示例和列出的两种解决方法。确定文档是否需要一个专门介绍如何设置嵌套 assigned content 样式的示例;完成的标准是将相关指导和示例添加到 lit.dev,并解答所报告的问题。
由索引模型根据 Issue 内容生成。
描述
Hi Team,
Could you please help us in applying the CSS to nested elements inside the slot.
Eg:
Render me in a slot
How can we apply the css to span with class redText inside a P tag which is a slot. It would be helpful if you can share some examples. I have already gone through your workarounds, but couldn't execute it.
Workaround 1 - Use Javascript To Style
(1) Access the slotted elements from javascript by using @queryAssignedElements (See https://lit.dev/docs/components/shadow-dom/#query-assigned-nodes)
(2) For each slotted element, parse its dom tree and style the child nodes using javascript (e.g. childelement.style.backgroundColor = '#ff0';)
Workaround 2 - Copy Slotted HTML to Another Div
(1) Access the slotted elements from javascript by using @queryAssignedElements (See https://lit.dev/docs/components/shadow-dom/#query-assigned-nodes)
(2) For every slotted element under consideration, copy-paste its outerHTML to another empty div, placed next to it.
(3) Since these initially empty divs are not from the slots, you can setup static css rules for them.
(4) Empty the slots after the copy pasting into the adjacent divs is complete.
Regards
Rajesh
- 主要语言
- TypeScript
- 星标
- 140
- 派生
- 229
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
lit/lit.dev 的其他 Issue
-
The example for `when` doesn't show that it takes the condition value as a parameter可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1-3 小时 新手友好度 72/100
-
难度 1/5 1 小时以内 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 62/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
GetStream/stream-chat-react#3467 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
vercel-labs/ui#1139 ·
维护者通常 1 天内回复
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bot:ai-assisted component:platform-js status:untriaged
难度 2/5 1-3 小时 新手友好度 82/100
midnightntwrk/platform-js#93 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100