INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

css show several items on hover

css show several items on hover

(OP)
I agreed to build a charity website, all is good and complete apart from an area on the homepage where they intend to show a graphic, hover over an area and that part changes, but also some text appears and a line changes colour to indicate it has been chosen.

I have attached an image showing what I mean. The first item is the default state, hover over the left circle and the circle changes slightly, a line appears, the dotted line changes colour and some text is displayed.

My question is how would I achieve this in css?

Thanks for any help

RE: css show several items on hover

If you have this image as uploaded to engineering.com you can use it as a links background-image, set background-repeat: no-repeat; and set the background-position-y triggered by hovering the circles areas of the following <map> section:

CODE -->

<map name="sitemap">
  <area shape="circle" coords="x1,y1,r" href="page1.htm" onmouseenter="javascript:call function to set background-position-y" onmouseleave="javascript:call function to reset background-position-y">
  <area shape="circle" coords="x2,y2,r" href="page2.htm" onmouseenter="javascript:call function to set background-position-y" onmouseleave="javascript:call function to reset background-position-y">
  <area shape="circle" coords="x3,y3,r" href="page3.htm" onmouseenter="javascript:call function to set background-position-y" onmouseleave="javascript:call function to reset background-position-y">
  <area shape="circle" coords="x3,y3,r" href="page4.htm" onmouseenter="javascript:call function to set background-position-y" onmouseleave="javascript:call function to reset background-position-y">
</map> 

You have to specify the coordinates of the circles and their approximate radius and define a javascript function to set the background-position-y to display part of the image for the corresponding circle or for no active circle.

Bye, Olaf.

RE: css show several items on hover

Depending on how that display is constructed (HTML, CSS) would be how to approach it.

Assuming the circles, the dotted lines, the text and the house are all a single image, but you have separate images for each button selection state you can simply change the image on hover of each area. You don't even need to muck around with background positions if all of them are the same size, you simply swap it, and the line and and text and hover effect appear from the image.

If All states are contained within the image i.e exactly as your uploaded image, then yes you would need to be moving the image around so the specific state is shown. Make sure the div that contains this image has overflow set to hidden in the CSS. If you do take this approach, make sure your image is well optimized if its going to be very large physically.

Personally to cut down on load times of a very large image I'd probably make 5 different optimized images and swap them.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: css show several items on hover

(OP)
I couldn't figure out how to achieve this using just css so for speed for now I have used jquery to add a class that updates the background position. The whole image is just 65kb so this will work fine for now until I have more time to revisit it later.

Thanks for the suggestions

RE: css show several items on hover

No real way to achieve it using only CSS. You do need Js in some form to alter the CSS.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close