【问题标题】:How do I apply a stylesheet just to the iPhone (and not IE), without browser sniffing?如何在没有浏览器嗅探的情况下将样式表仅应用于 iPhone(而不是 IE)?
【发布时间】:2010-10-23 00:17:01
【问题描述】:

我想将样式表专门应用于 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 应用。

【问题讨论】:

    标签: iphone css internet-explorer ios mobile-safari


    【解决方案1】:

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

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

    感谢Sitepoint’s iPhone development article

    【讨论】:

      猜你喜欢
      • 2013-05-02
      • 2023-04-08
      • 2011-09-02
      • 2011-10-30
      • 2013-12-31
      • 2012-08-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多