6

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 Answer 1

12

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.

2
  • You saved the day (two years later)!
    – d-_-b
    Commented Sep 9, 2012 at 3:48
  • 1
    >The + selector looks for the next adjacent sibling. So, how to display #hidden when it is BEFORE of #show? Commented Jan 6, 2014 at 12:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.