也许尝试使用这些定义您的浏览器及其版本的函数,并在您的html标签中编写,<html class="<?php echo getBrowser();?>">
然后在您的css中您可以为不同的浏览器编写样式,例如,如果您使用的是chrome 23,您将拥有html标签喜欢<html class="chrm chrm23">
,所以在你的CSS中你可以写
.chrm .yourClass { /* 这里的属性*/ }
function getBrowser() {
global $_SERVER;
$firefoxStart = strrpos($_SERVER['HTTP_USER_AGENT'], 'Firefox');
$chromeStart = strrpos($_SERVER['HTTP_USER_AGENT'], 'Chrome');
$safariStart = strrpos($_SERVER['HTTP_USER_AGENT'], 'Safari');
if ($firefoxStart !== false){
$version = $this->getVersion($firefoxStart, 8);
return "ff ff" . $version;
}elseif ($chromeStart !== false){
$version = $this->getVersion($chromeStart, 7);
return "chrm chrm" . $version;
}elseif ($safariStart != false){
$version = $this->getVersion($safariStart, 7);
return "sfr sfr" . $version;
}
}
private function getVersion($start, $length){
global $_SERVER;
$end = strpos($_SERVER['HTTP_USER_AGENT'], ' ', $start);
if ($end === false){
$end = strlen($_SERVER['HTTP_USER_AGENT']);
}
$versionStr = substr($_SERVER['HTTP_USER_AGENT'], $start + $length, $end - $start - $length);
$version = floatval($versionStr);
$version = str_replace('.', '', $version);
return $version;
}