本文介绍了悬停在父元素上时样式子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当父元素悬停时如何改变子元素的样式.如果可能的话,我更喜欢 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.
这篇关于悬停在父元素上时样式子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!