Jump to content

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


kate_rose

Recommended Posts

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 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.