How to change div background image when hovering without jQuery?

I want to change the background of the DIV to a hover event. Is there a way to do this using pure CSS?

+6
css image background
source share
1 answer

Yes, it's pretty easy with pure CSS, although IE6, if I remember correctly, does not support :hover for any elements other than a . But the following should work consistently in other browsers:

 div { background: #fff url(path/to/image.png) 0 0 no-repeat; } div:hover { background: #ffa url(path/to/hoverImage.png) 0 0 no-repeat; } 
+8
source share

All Articles