-3

How to display hidden css classes on hover

<a class="a1">Show the first</a>
<a class="a2">Show the second</a>

<div class="div1">The first</div>
<div class="div2">The second</div>

I think it's clear

thanks!

Ahmed
  • 9
  • 5

2 Answers2

2

A CSS only option would be to have 2 classes and with one you hide the div element as with the others you display it using the pseudo selector :hover

div {
    display: none;
}

a:hover + div {
    display: block;
}
Mite Mitreski
  • 3,596
  • 3
  • 29
  • 39
1

You can use the general sibling selector:

div { display: none; }
.a1:hover ~ .div1 { display: block; }
.a2:hover ~ .div2 { display: block; }

http://jsfiddle.net/uK8KP/

bfavaretto
  • 71,580
  • 16
  • 111
  • 150