Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change a div background image while hover without jQuery?

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

like image 939
Selvin Avatar asked Mar 19 '11 11:03

Selvin


1 Answers

Yeah, this is pretty easy with pure CSS, albeit IE6, if I remember rightly, doesn't support :hover on any elements except for 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;
}
like image 91
David Thomas Avatar answered Oct 10 '22 00:10

David Thomas