Solved

Image Hover Over change with One jpeg image

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sort Order Icons on HTML Table 3 58
social media icons disappear on small screens 4 26
CSS in HTML 5 51
Popup write two lines 3 22
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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 customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

713 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