Style child element when hover on parent(悬停在父元素上时样式子元素)
问题描述
当父元素悬停时如何改变子元素的样式.如果可能的话,我更喜欢 CSS 解决方案.是否有任何解决方案可以通过 :hover CSS 选择器.实际上,当面板上悬停时,我需要更改面板内选项栏的颜色.
How to change the style of child element when there is hover on parent element. I would prefer a CSS solution for this if possible. Is there any solution possible through :hover CSS selectors. Actually I need to change color of options bar inside a panel when there is an hover on the panel.
希望支持所有主流浏览器.
推荐答案
是的,你绝对可以做到这一点.只需使用类似的东西
Yes, you can definitely do this. Just use something like
.parent:hover .child {
/* ... */
}
根据this page所有主流浏览器都支持.
According to this page it's supported by all major browsers.
这篇关于悬停在父元素上时样式子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:悬停在父元素上时样式子元素
基础教程推荐
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
