简体   繁体   English

鼠标悬停在IE7中不起作用?

[英]mouse hover is not working in IE7?

I have below HTML code. 我有下面的HTML代码。

<input type="button" class="myButton" value="Text"></input>

CSS CSS

input.myButton{
    background: url("../images/button.png") no-repeat top left;
    height: 21px;
    cursor: pointer;
    width: 78px;
    text-align: center;
    color: #696969;
    font-family: Arial,Helvetica,sans-serif;
    font-size: 11px;
    border: medium none white;
}
input.myButton:hover{
   background: url("../images/button-active.png") no-repeat top left;
   color: #FFFAF0;
}

But mouse hover is not working in IE7. 但是鼠标悬停在IE7中不起作用。 I would like to change the image :hover . 我想更改图像:hover

How can i do this? 我怎样才能做到这一点? it works fine in FireFox browser. 它在FireFox浏览器中正常工作。

Thanks! 谢谢!

I think IE7 is so old hover doesn't work on anything but a . 我认为IE7太旧悬停不上任何东西,但工作a I remember this used to be a problem in IE. 我记得这曾经是IE中的问题。

You can write a workaround that uses an onmouseover/out listener that sets a class. 您可以编写一种解决方法,该方法使用设置类的onmouseover/out侦听器。

您最好使用jquery,因为IE中的CSS悬停支持因版本而异

在IE中,必须声明一个<!DOCTYPE> ,以便:hover选择器可以在<a>元素以外的其他元素上工作,这里: http : //www.w3schools.com/cssref/sel_hover.asp

The specification for IE7 is that the :hover pseudo class will only work on the a tag. IE7的规范是:hover伪类只能在a标签上使用。 You can get around this by using a polyfill. 您可以通过使用polyfill来解决此问题。 I would highly recommend Selectivizr . 我强烈推荐Selectivizr It allows you to use most pseudo classes on older, or unsupported, browsers. 它允许您在较旧的或不受支持的浏览器上使用大多数伪类。

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

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