为什么$(' html').animate()仅在IE中有效,而Chrome(Chrome)/Safari需要$(' body').animate()? [英] How come $('html').animate() only works in IE and $('body').animate() is needed for Chrome/Safari?

查看:49
本文介绍了为什么$(' html').animate()仅在IE中有效,而Chrome(Chrome)/Safari需要$(' body').animate()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用 $('html,body').animate()来使代码段完全跨浏览器兼容,但这在链接动画时很不方便,因为它们有时会同时作用于两个动画上< html> < body> .

I have to use $('html, body').animate() to make the snippet fully cross-browser compatible, but this is inconvenient when chaining animations as they will sometimes act on both <html> and <body>.

IE8依赖于具有'html',而Chrome或Safari依赖于具有'body',因此我必须同时包含两者.

IE8 depends on having 'html' while Chrome or Safari depend on having 'body', so therefore i must include both.

为什么会有差异?

推荐答案

我认为这是因为滚动条(我认为您正在制作动画)是内置在浏览器中的不同位置.我以前遇到过这个问题,不得不使用与您合并的方法相同的方法.有点烦人,但是当您希望它们在所有浏览器中都能正常工作时,大多数事情也是如此:-)

I think it's because the scroll bars (that I presume you're animating) are built into the browser at different locations. I've had this problem before and had to use the same method you incorporate. Bit annoying, but then so are most things when you want them to work across all browsers :-)

这篇关于为什么$(&amp;#39; html&amp;#39;).animate()仅在IE中有效,而Chrome(Chrome)/Safari需要$(&amp;#39; body&amp;#39;).animate()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆