详细信息摘要H4悬停颜色

发布于 2025-01-19 10:57:19 字数 382 浏览 3 评论 0原文

我试图在悬停时为详细摘要内的 h4 文本着色,但颜色更改仅在直接悬停在实际 h4 文本上时才会生效,如何修改我的 CSS 以在悬停在其他部分上时更改 h4 文本颜色摘要栏?

Codepen - 实际代码从第 62 行开始(第 1-59 行只是设置环境样式,以便我的代码可以预见地转移到我的主题)

.accordion-button:not([open]) h4:hover,
.accordion-button:not([open]) h4:focus {
  color: var(--color-button-text);
}

I am trying to color the h4 text inside a details summary upon hover, but the color change only takes effect when hovering DIRECTLY OVER the actual h4 text, how can I modify my CSS to change the h4 text color when hovering over other parts of the summary bar?

Codepen - actual code starts @ line 62 (lines 1-59 are just setting environment styles so that my code is predictably transferable to my theme)

.accordion-button:not([open]) h4:hover,
.accordion-button:not([open]) h4:focus {
  color: var(--color-button-text);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必在意 2025-01-26 10:57:19

您需要移动:悬停到父元素:

.accordion-button:not([open]):hover h4,
.accordion-button:not([open]):focus h4 {
  color: var(--color-button-text);
}

You need move :hover to the parent element:

.accordion-button:not([open]):hover h4,
.accordion-button:not([open]):focus h4 {
  color: var(--color-button-text);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文