This is exactly something I need, but it doesn't work for me, so can I ask
you to be a bit more specific? I put the "small" class in my img tag, and
added a width and height for large:
.large
{
width: 50px;
height: 50px;
visibility: hidden;
}
.small: hover .large
{
visibility: visible;
}
<a href="/" title=""><img src="icon.png" class="small" alt="" /></a>
So why does it not work? What am I missing?
First thing is you need to lose the space between .small: hover (i.e.
..small:hover).
Second point is that this is a descendent selector:
..small:hover large
{
...
}
selects anything with a class of "large" that's a descendent (i.e.
nested inside) anything with a class of "small" that's also being
hovered over.
In your example, there's nothing with class "large", and the img, which
has class "small" has no descendents. So nothing matches the selector.
One way of doing it is this:
<style type="text/css">
/* big thing inside an anchor-- basically don't display it */
a .big
{
display: none;
}
/* big thing inside a hovered anchor-- do display it */
a:hover .big
{
display: inline;
}
/* small thing inside a hovered anchor-- don't display it */
a:hover .small
{
display: none;
}
</style>
...
<a href="#">
<img src="small.png" class="small"></img>
<img src="big.png" class="big"></img>
</a>
Note also the difference between "display: none" and "visibility:
hidden". display:none means carry on as if the element weren't there at
all, visibility:hidden means leave a hole in the page for it, but make
it invisible.