如果在 ipad 或 iphone 等触摸屏设备上查看页面,我需要向页面加载一些额外的 CSS。最简单的方法是什么?
谢谢
对于 iPad,您可以尝试:
if (window.Touch)
{
alert("touch my ipad/iphone/ipod");
}
else
{
alert("no touch!");
}
我斗胆猜测 iPhone 的工作原理也是一样的。
您还可以使用 CSS 媒体查询来生成如下内容:
<link rel="stylesheet" media="all and (max-device-width: 480px)" href="iphone.css">
<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)" href="ipad-portrait.css">
<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)" href="ipad-landscape.css">
<link rel="stylesheet" media="all and (min-device-width: 1025px)" href="ipad-landscape.css">
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)