Show div on hover without Javascript
If you'd like to see this live on jsfiddle instead, click here
If you are making a website that should be compatible without javascript, or just don't want to slow down the page with lots of scripts, this is a great trick. And it's really easy.
First of all you need to hide the div that's going to be shown on hover of something (let's say on hover of an image, since that's very typical). This is really easy in CSS, a little display:none; should do the trick.
#showonhover{ display:none; }
Now we are going to make the whole show on hover thing. Here's how:
<style> #showonhover{ display:none; } .showdiv:hover #showonhover{ display:block; /* when .showdiv is hovered, #showonhover will be visible */ } </style> <div class="showdiv"> <div id="showonhover"></div> </div>
That's it. When .showdiv is hovered, #showonhover will be visible, when it's not, #showonhover won't be visible.