【问题标题】:loading css for iPad useragent in PHP在 PHP 中为 iPad 用户代理加载 CSS
【发布时间】:2013-07-13 13:03:58
【问题描述】:

我知道如果您想针对 iPad 和 iPhone 使用媒体查询和 JavaScript 来加载 CSS 类,但可以使用 PHP 并且如果用户代理是 iPad 加载“iPad.css”或 iPhone 加载“ iPhone.css”并删除默认的“style.css”?

【问题讨论】:

    标签: php iphone css ipad user-agent


    【解决方案1】:

    你可以在 php 中这样做:

    <?php
    $isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
    
    if ($isiPad == true) { 
    ?>
    <link rel="stylesheet" href="ipad.css">
    <?php
    } else {
    ?>
    <link rel="stylesheet" href="nonipad.css">
    <?php } ?>
    

    【讨论】:

    • 如何删除当前的 css 文件?
    • 你可以把nonipad css放在else里,这样你就不用同时加载了
    【解决方案2】:

    也许你应该检查客户端浏览器

    $_SERVER['HTTP_USER_AGENT']
    

    【讨论】:

      猜你喜欢
      • 2014-02-02
      • 1970-01-01
      • 2011-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-15
      相关资源
      最近更新 更多