Solved

Image Hover Over change with One jpeg image

Posted on 2014-09-11
2
178 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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

792 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