-1

我有一个使用文本字段的网站。在 Firefox 中,我使用 css。但是当我在谷歌浏览器中打开我的网站时,我得到了不同的网站设计。

我认为解决方案是为不同的浏览器提供不同的 css 文件。所以我需要知道以下用户使用的浏览器。然后更改css的链接..示例:

<link href='Site_Css/firefox.css' rel='stylesheet' type='text/css' />

那么如果用户使用谷歌浏览器,

<link href='Site_Css/firefox.css' rel='stylesheet' type='text/css' />
4

2 回答 2

0

您可以拉取 的browser属性get_browser()。请注意,这是昂贵的。

附带说明一下,实际上不需要为 Chrome 和 Firefox 包含单独的样式表。不同的浏览器确实以不同的方式处理某些 CSS 属性,但几乎总是有一个纯 CSS 的解决方法。

于 2013-05-19T11:11:17.160 回答
0
<?php

// check what browser the visitor is using
  $user_agent = $_SERVER['HTTP_USER_AGENT'];

// This bit differentiates IE from Opera
if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) 
    { 
      print
        'This is Internet Explorer. (Insert joke here)';        
    } 
    elseif(preg_match('/mozilla/i',$u_agent) && !preg_match('/compatible/', $userAgent)) 
    { 
      print
        'This is FireFox.';
    } 
// let Chrome be recognized as Safari
    elseif(preg_match('/webkit/i',$u_agent)) 
    { 
      print
        'This is either Chrome or Safari.';
    } 
    elseif(preg_match('/Opera/i',$u_agent)) 
    { 
      print
        'This is Opera. Like to live on the edge, huh?';
    } 
    elseif(preg_match('/Netscape/i',$u_agent)) 
    { 
      print
        'This is Netscape, and you really need to upgrade.';
    } 

?>
于 2013-05-19T11:35:33.953 回答