Solved

Image Hover Over change with One jpeg image

Posted on 2014-09-11
2
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 40317678
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
ID: 40325353
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

738 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