4

我想将样式表专门应用于 iPhone,而不是在服务器上或通过 JavaScript 进行浏览器嗅探(通过用户代理字符串)。

我特别不希望 Internet Explorer 应用样式表。Apple 建议的应用 iPhone 特定样式表的代码,即:

<link media="only screen and (max-device-width: 480px)" href="small-device.css" type= "text/css" rel="stylesheet">

似乎导致样式表被 IE 7 和 6 应用。

4

1 回答 1

15

使用 Apple 建议的代码,但将其包装在条件注释中以将其隐藏在 IE 中:

<!--[if !IE]><!-->
<link media="only screen and (max-device-width: 480px)" href="small-device.css" type= "text/css" rel="stylesheet">
<!--<![endif]-->

我认为这要归功于 Sitepoint 的 iPhone 开发文章

于 2009-04-30T23:12:47.917 回答