I want to change the background of a DIV on hover event. Is there a way to do this using pure CSS?
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With