Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used content tag in css for the on hover function as I have given an id to the image tag.But, the on Hover is not working in Firefox and IE and it's working fine in chrome. Here is the link to this : thunderstorm999.byethost9.com

HTML
<ul class="navigation">
<li><a href="#"><img id="explore" src="images\explore.png"/></a></li>
<li><a href="#"><img id="material" src="images\material.png"/></a></li>
<li><a href="#"><img id="team" src="images\team.png"/></a></li>
<li><a href="#"><img id="contact" src="images\contact.png"/></a></li>
<li><a href="#"><img id="merchandise" src="images\merchandise.png"/></a></li>
</ul>


CSS
#explore:hover {
    content: url('images/explore-hover.png');
}
#material:hover {
    content: url('images/material-hover.png');
}
#team:hover {
    content: url('images/team-hover.png');
}
#contact:hover {
    content: url('images/contact-hover.png');
}
#merchandise:hover {
    content: url('images/merchandise-hover.png');
}
Posted
Comments
Kornfeld Eliyahu Peter 15-Feb-15 5:21am    
Did you saw what the built in debugger of each have to say about it?
Ankit Gada 15-Feb-15 7:11am    
Didn't get you..

1 solution

Firefox has an allergy to non-standard uri... 'images\...png' is not one, so it refuses to display...Use / instead of \ to get the correct path in each browser...
As for both...There is some problem with the content attribute...You face one of the rare cases where IE (and Firefox too) enforces standard...
This attribute can be used - by CSS standard - only in the context of :before and :after pseudo-selectors...
Other browsers allow to use content out-of context, but it is not by the standard, and maybe removed in coming versions...
To be honest with you, you can not change the src attribute of an img tag using CSS...
You can do a workaround using background-image attribute to do so (there are samples you can find with Google easily)...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900