问题描述
我正在尝试查找一个脚本,用于检测设备是否放置位置:固定
相对于ViewPort的元素,而不是整个文档。
I am trying to find a script that detects if a device places position: fixed
elements relative to the ViewPort and not to the entire document.
目前,标准桌面浏览器和Mobile Safari(适用于iOS 5)这样做,而Android设备将固定元素相对于整个文档放置。
Currently, standard desktop browsers and Mobile Safari (for iOS 5) do so, whereas Android devices place the fixed elements relative to the entire document.
我找到了几个检测这个的测试,但似乎都没有用:
I have found a couple of tests to detect this, but none of the seem to work:
- 当我从Android设备传递它时,给我一个误报。
- 给我一个当我在带有iOS 5的iPhone中传递它时出现假阴性。
- http://kangax.github.com/cft/ Gives me a false positive when I pass it from an Android device.
- https://gist.github.com/1221602 Gives me a false negative when I pass it in an iPhone with iOS 5.
是否有人知道在哪里找到/如何编写实际的测试检测到了吗?我不想依赖浏览器嗅探。
Does anybody know where to find / how to write a test that actually detects that? I don't want to rely on browser sniffing.
推荐答案
根据,如果不检测正在使用的浏览器,则无法执行此操作。贡献者在该领域非常成熟。
According to the contributors at Modernizr, you cannot do this without detecting the browser in use. The contributors are quite well-established in the field.
在iOS和Android设备上测试位置:固定
是在Modernizr项目的下列出。
Testing for position: fixed
on iOS and Android devices is listed under the Undetectables wiki page in the Modernizr project.
列出了对位置的支持:已修复
。
这篇关于位置特征检测:固定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!