jQuery 的 fadeIn() 和 fadeOut() 不适用于 IE 8 吗?
我有一个页面,其中 fadeIn 和 fadeOut 是内联元素,但 jQuery 不起作用。然后当我将开发工具更改为使用 IE 7 的浏览器模式时,就会显示 fadeIn() 和 fadeOut() 效果。
I have a page that fadeIn and fadeOut an inline element and jQuery doesn't work. And then when I change the Developer Tools to use Browser Mode of IE 7, then the fadeIn() and fadeOut() effect is showing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IE 有一个称为“hasLayout”的实现细节,遗憾的是,它经常泄漏 API 抽象,必须正面处理...这就是您今天面临的战斗:内联元素通常不会有“布局”并且因此不能与“过滤器”一起使用...jQuery 使用过滤器来模拟 IE 上的不透明度。
这在 IE8 中并不是什么新鲜事,通常你根本不必担心它,因为 jQuery 正是要掩盖这种特定于浏览器的疯狂行为......事实上,这就是为什么我不打扰的原因详细了解“hasLayout”和“过滤器”的实际含义 - 你可能不关心,也不应该关心(但是,如果你有兴趣,谷歌它......)
问题是,黑客jQuery 在幕后使用强制布局(因此过滤器可以工作(因此它可以模拟不透明度(因为 IE 没有实现它)))...它在 IE8 上不起作用。 那不是很棒吗?他们修复了
display: inline
元素表现为display: inline-block
元素的错误,但忽略了实现人们利用他们的错误来破解支持的功能。 ..好吧,对此你无能为力。给 IE 团队写一封令人讨厌的电子邮件可能会让你感觉好一点,但他们正在努力开发 IE9,这应该(敲木头......)解决大部分问题。与此同时,您只需要手动执行 IE 曾经所做的事情(有点,有点,而且肯定是错误的):强制内联元素进入内联块模式:
.. .或者更好的是,将其放入仅 IE8 的样式表...
IE has an implementation detail known as "hasLayout" that, sadly, often leaks past the API abstraction and must be dealt with head-on... This is the battle you face today: inline elements generally won't have "layout" and thus won't work with "filters"... which are what jQuery uses to simulate opacity on IE.
This isn't new in IE8, and normally you wouldn't have to worry about it at all since it's exactly this sort of browser-specific madness that jQuery is intended to paper over... Indeed, that's why I'm not bothering to go into detail on what "hasLayout" and "filters" actually mean - you probably don't care, and shouldn't have to (but, if you're interested, google it...)
Problem is, the hack that jQuery uses under the hood to force layout (so filters work (so it can simulate opacity (since IE doesn't implement it)))... it doesn't work on IE8. Ain't that just great, eh? They fixed the bug whereby
display: inline
elements behaved asdisplay: inline-block
elements, but neglected to implement the feature that folks were using their bug to hack in support for...Well, nothin' you can do about that. Writing a nasty email to Team IE might make you feel a bit better, but they're hard at work on IE9, which should (knock on wood...) fix most of these problems. In the meantime, you'll just have to do manually what IE used to do (kinda, sorta, and most certainly incorrectly) all by itself: force the inline element into inline-block mode:
...or better yet, put it in an IE8-only stylesheet...