简体   繁体   English

CSS选择器“悬停”不适用于我的HTML代码

[英]The CSS selector “hover” is not working on my HTML code

For some reason, my :hover isn't working. 由于某种原因,我的:hover无法正常工作。 Here's my CSS code: 这是我的CSS代码:

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

And my HTML 还有我的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? 有什么想法为什么不起作用?

It's working - you just have to correct your CSS rules. 它正在工作-您只需要更正CSS规则即可。

For border you have to specify its width and style, not just color. 对于border您必须指定其宽度和样式,而不仅仅是颜色。 Same for the box-shadow - the color itself isn't enough. box-shadow -颜色本身还不够。

 .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> 

class =“ image”需要移到您的A标签

Seems to be working just fine: 似乎工作正常:

You have some pink background on hover... Firefox 11.0 on Ubuntu 11.10 here. 您的鼠标悬停了一些粉红色背景。Ubuntu 11.10上的Firefox 11.0在这里。

Here's an update for border and box-shadow : 这是borderbox-shadow的更新:

but you can of course tune to your taste. 但您当然可以根据自己的喜好进行调整。 Hope this helps. 希望这可以帮助。

也许header.png是不透明的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM