CSS change parent's background on hover?

允我心安 提交于 2020-01-06 06:58:26

问题


I have a dropdown menu and want to change background of parent's button when hovering submenus. Any ideas how to achieve this so it will work not only in all modern browsers but preferably in IE8/IE9 too?

Simple example, I want to change background of link "This black" while hovering his children ("When hover me" & "and me").

Is it possible with pure CSS?

http://jsfiddle.net/PExLW/

I was thinking about adding certain classes when hovering certain li but it sounds like an overkill, also, adding classes on hover doesn't sound like a good idea.


回答1:


sure, just take out the a

ul li:hover { ... }

example jsfiddle (or fullscreen)



来源:https://stackoverflow.com/questions/12849536/css-change-parents-background-on-hover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!