css pseudoclass:hover not working

匆匆过客 提交于 2019-12-07 04:46:46

问题


I am struggling to get a simplest css hover pseudoclass to work. Anybody knows why the following doesnt work?

the css

#hidden {display:none;}
#show:hover #hidden{display:block;}

the html

<a href="#" id="show">show</a>
<div id="hidden">here i am</div>

I really feel stupid asking such a simple question, i did this a hunderd times, but cant figure out why this shouldnt work.


回答1:


Try this

#show:hover + #hidden{display:block;}

:hover #hidden implies that #hidden is a child of the hover element. The + selector looks for the next adjacent sibling.



来源:https://stackoverflow.com/questions/3847568/css-pseudoclasshover-not-working

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