检查iOS版本是否≥4.2并根据结果修改CSS
我正在使用 Typekit.com 在网站上显示 cufonts,但是,它仅与移动浏览器 >= 4.2 iOS 兼容。我已经使用 jQuery 来测试访问者是否使用 iOS 并根据过去的内容显示特定内容(不费吹灰之力),但我在弄清楚如何更具体并仅修改 CSS 方面遇到了很大的麻烦如果版本低于 iOS 版本 4.2。似乎无法弄清楚这一点...有什么帮助吗?
I am using Typekit.com to display cufonts on a site, however, it is only compatible with mobile browsers >= 4.2 iOS. I have used jQuery to test if the visitor is using iOS and to display specific content based on that in the past (no sweat), but I'm having a great deal of trouble figuring out how to be more specific and revise the CSS ONLY IF the version is LESS than iOS version 4.2. Can't seem to figure this out... any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将您的 4.2+ 样式放入一个样式表中。将您的 <4.2 样式放入另一个样式中。检查版本并将适当的样式表添加到
中。您需要测试较旧的用户代理字符串,但这应该适用于大多数情况。该函数返回
0
(如果它无法确定或者不是 iOS)作为“旧”样式表的后备。演示: http://jsfiddle.net/ThinkingStiff/LJrEW/
脚本:
Put your 4.2+ styles into one stylesheet. Put your <4.2 styles into another. Check the version and add the appropriate stylesheet to the
<head>
. You'd need to test older user agent strings, but this should work with most. The function returns0
(if it can't determine or if it's not iOS) as a fallback to the "old" stylesheet.Demo: http://jsfiddle.net/ThinkingStiff/LJrEW/
Script:
您可以使用用户代理来获取设备正在运行的特定 ios 版本。
You can use the user-agent to get the specific ios version the device is running.