0

For some reason, my :hover isn't working. Here's my CSS code:

.image:hover
{
    border:#000000;
    background-color:#FF66FF;
    box-shadow:rgb(0,255,153);
}

And my HTML

 <div id="header">
    <a href="index.html"><img src="header.png" class="image" onload="ChangeColors(this)" /></a>
 </div>

Any ideas on why this isn't working?

5
  • which browser is it not working in? Commented Feb 21, 2012 at 0:42
  • What's onload="ChangeColors(this)"? Commented Feb 21, 2012 at 0:44
  • Can you post a jsFiddle, please? Commented Feb 21, 2012 at 0:44
  • @AntonyScott Firefox. elclanrs: It's a function that changes the color of my logo to a random color (not related). Commented Feb 21, 2012 at 0:48
  • A note: you can omit the <a>...</a> and merge href into the img tag, and it has the same effect. Commented May 10, 2012 at 22:09

4 Answers 4

2

It's working - you just have to correct your CSS rules.

For border you have to specify its width and style, not just color. Same for the box-shadow - the color itself isn't enough.

.image:hover {
  border: 2px solid #000000;
  background-color:#FF66FF;
  box-shadow: 10px 10px 5px rgb(0,255,153);
}
<div id="header">
  <a href="index.html"><img src="http://placehold.it/300x150" class="image" /></a>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks... I felt kinda dumb not being able to work out a problem as simple as that lol.
0

The class="image" needs moving to your A tag

Comments

0

Seems to be working just fine:

You have some pink background on hover... Firefox 11.0 on Ubuntu 11.10 here.

Here's an update for border and box-shadow:

but you can of course tune to your taste. Hope this helps.

Comments

0

Perhaps header.png is not transparent?

1 Comment

I notice you are trying to change its background color.

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.