Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css pseudoclass:hover not working

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.

like image 837
Hans Avatar asked Oct 02 '10 21:10

Hans


People also ask

Why is my hover CSS not working?

Also, hover will not work if you use the wrong CSS format. Note that if you do not get the specificity right, the hover style will not work. Although you can use the ! important rule, there is no guarantee it will always work.

Can you hover a pseudo element?

The :hover CSS pseudo-class matches when the user interacts with an element with a pointing device, but does not necessarily activate it. It is generally triggered when the user hovers over an element with the cursor (mouse pointer).

Why Hover is not working on div?

You might have linked your stylesheet to your HTML file improperly. Some other CSS in the context of your project may be overriding the piece that you've given here. You might be running into browser compatibility issues with the :hover selector or something else in your code that is breaking the styling.

What does the pseudo class hover do?

A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example, the pseudo-class :hover can be used to select a button when a user's pointer hovers over the button and this selected button can then be styled.


1 Answers

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.

like image 153
meder omuraliev Avatar answered Sep 29 '22 11:09

meder omuraliev