div 中的子元素在 IE 中不会 fadeTo()

发布于 2024-08-20 21:13:19 字数 708 浏览 4 评论 0原文

这对我来说很奇怪。此代码:

$(".layover").fadeTo("fast", 0.0);
$(".layover").hover(function() {
$(this).fadeTo("fast", 0.9);
},
function() {
$(this).fadeTo("fast", 0.0);
});

..在除 IE7 和 IE8 之外的所有浏览器上运行良好。它甚至可以(缓慢地)在 IE6 中运行(尖叫!)在 IE7 和 IE8 中,此代码不会淡出子元素,即 img 标签。 img 只是坐在那里不受影响。但是,如果我在 IE8 中启用“兼容模式”,它就会按预期工作。请参阅此示例页面

我的 JavaScript 中是否缺少一些可以帮助 IE 正常运行的内容?我可以在 IE 中强制兼容模式吗?

我知道有人会对 FOUC 发表评论。我也在做这方面的工作。

更新:这是 CSS 部分

div.layover {
position:absolute;
padding:0px;
display:inline-block;
background-color:#fff;
height:106px;
width:312px;
}

This is strange to me. This code:

$(".layover").fadeTo("fast", 0.0);
$(".layover").hover(function() {
$(this).fadeTo("fast", 0.9);
},
function() {
$(this).fadeTo("fast", 0.0);
});

..works just fine on all browsers except IE7 and IE8. It even works (slowly) in IE6 (screams!) In IE7 and IE8 this code will NOT fade out child elements namely img tags. The img just sit there unaffected. However, if I enable "compatibility mode" in IE8, it works as expected. See this example page.

Is there a bit I'm missing in my JavaScript to help IE play nice? Can I force compatibility mode in IE?

And I know someone is going to comment on the FOUC. I'm working on that too.

UPDATE: Here's the CSS portion

div.layover {
position:absolute;
padding:0px;
display:inline-block;
background-color:#fff;
height:106px;
width:312px;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够钟 2024-08-27 21:13:19

这并没有回答你的主要问题,但我相信将你的第一行更改为这将有助于修复你的 FOUC:

$(".layover").hide();

This doesn't answer your main question, but I believe changing your first line to this would help fix your FOUC:

$(".layover").hide();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文