Solved

Image Hover Over change with One jpeg image

Posted on 2014-09-11
2
167 Views
Last Modified: 2014-09-30
I have been tasked with writing multiple CSS classes for one image.  It is basically a social bar that when you hover over the link, the link changes color.  There is one image that contains 4 images meant for hover over and one image meant for the default image before hover over.  When the user hovers over the image or link, the css coordinates change to be another image within the one jpeg image to show the hovered image.  How am I supposed to do this so that it works?  The image looks like the following: SEE ATTACHED IMAGE.socialbar.jpg
0
Comment
Question by:VBBRett
2 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 250 total points
Comment Utility
That is a 'sprite' image.  The CSS will declare a 'div' with the right dimensions to show only one of the images and the background position will be adjusted so the correct one shows thru.  When you 'hover' over it, the CSS 'hover' code will change the background position to show the image of the other color.  More info here: http://www.w3schools.com/css/css_image_sprites.asp
0
 
LVL 13

Assisted Solution

by:Abhijeet Rananaware
Abhijeet Rananaware earned 250 total points
Comment Utility
You can use background-position property for changing position on spirite image.

divimage{
       display: block;
       background: url(sprite.png) no-repeat;
       height: 30px;
       width: 250px;
}

divimage:hover {
       background-position: 0 -30px;
}

Open in new window


Adjust background-position for each hover .
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now