CSS On hover show another element

user2770029 picture user2770029 · Sep 11, 2013 · Viewed 103.4k times · Source

I want to use CSS to show div id='b' when I hover over div id='a', but I cannot figure out how to do it because the div 'a' is inside another div that div 'b' is not in.

<div id='content'>
     <div id='a'>
         Hover me
     </div>
</div>
<div id='b'>
    Show me
</div>

Answer

Ankit Agrawal picture Ankit Agrawal · Sep 11, 2013

we just can show same label div on hovering like this

<style>
#b {
    display: none;
}

#content:hover~#b{
    display: block;
}

</style>