7

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

1 Answer 1

9

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;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.