Jump to content

can I use hover to change the content of another div?


kate_rose

Recommended Posts

Well you got the question from the subject line...

I know I can do it in javascript with hotspots but was hoping for a more elegant solution.

 

Thanks,

 

Kate

 

so you only want to do this with css and no javascript; is that what your wanting?

I have just been so impressed with the ease of rollovers with the use of the hover command in CSS, I was just wondering if there was a way to make the hover command change the content of another div (other than that being hovered over).  If not I can certainly do it with Javascript if you think it would be easier.

 

Thanks,

Kate 

There is no way to do it across all browsers with css applied to the same html, because IE6 and below don't support the :hover pseudo-class on anything other than anchors.

 

But you could do it for other browsers by applying :hover to other elements in the stylesheet and making sure that in the html the content to be revealed is contained within the element that is having the :hover pseudo-class applied to it in the css.

 

.myclass .hidden {display:none;}
.myclass:hover .hidden {display:block;}

<ul>
  <li class="myclass">
    <div class="hidden">You can't see me until you hover on my parent.</div>
  </li>
</ul>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.