Html 悬停效果不适用于 IE8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6269831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 08:59:16  来源:igfitidea点击:

Hover effects not working with IE8

htmlcssinternet-explorer-8hoverdoctype

提问by Lazer

I used CSS for a color change on hover for a table

我使用 CSS 在表格悬停时更改颜色

#tabb tbody tr:hover td{
    color:#006;
    background:#d0e4f2;
}

This works fine in Chrome and Firefox, but the hover effect does not happen in Internet Explorer 8.

这在 Chrome 和 Firefox 中工作正常,但在 Internet Explorer 8 中不会发生悬停效果。

Is there a way to make this effect work with IE8 as well?

有没有办法使这种效果也适用于 IE8?

回答by thirtydot

That shouldwork fine in IE8.

这在 IE8 中应该可以正常工作。

A stab in the dark:

暗中刺伤:

Make sure you have a doctypeas the very first line of your HTML that triggers Standards Mode, such as:

确保您有一个 doctype作为触发标准模式的 HTML 的第一行,例如:

<!DOCTYPE html>

In Quirks Mode, IE emulates version 5.5, which does not support :hoveron elements other than a.

Quirks模式,IE模拟版本5.5,不支持:hover在除了其他元件a

回答by Wex

IE8 is not the usual culprit for :hoverproblems. If you can't get it to work, there's always jQuery!

IE8 不是通常的:hover问题的罪魁祸首。如果你不能让它工作,总是有 jQuery!

$("#tabb tbody tr").hover(
    function() {
        $("this").children("td").css( { 'background-color': '#d0e4f2', 'color': '#006' } );
    },
    function() {
        $("this").children("td").css( { ... } );
    }
);

回答by Patricia

my guess is something wonky in your html code for the table. as you can see on this quick and dirty fiddle, your css is a-ok:

我的猜测是您的表格 html 代码中的某些内容很奇怪。正如您在这个快速而肮脏的小提琴上看到的那样,您的 css 还可以:

http://jsfiddle.net/PwZsN/

http://jsfiddle.net/PwZsN/