Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 对于chrome和safari是否有任何等同于IE的条件注释?_Css_Safari_Webkit_Google Chrome - Fatal编程技术网

Css 对于chrome和safari是否有任何等同于IE的条件注释?

Css 对于chrome和safari是否有任何等同于IE的条件注释?,css,safari,webkit,google-chrome,Css,Safari,Webkit,Google Chrome,我想知道是否有什么东西像ie对webkit的条件评论一样有效 我想改变宽度 比如说, <!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css" /> <![endif]--> 提前谢谢 没有 您可以通过在JS中执行浏览器检测并动态附加脚本/样式来破解它 或者,如果您只关心为不同的浏览器使用不同的css,您可以使用css黑客。可能有一些css黑客可以使用您需要的浏览器 或者,

我想知道是否有什么东西像ie对webkit的条件评论一样有效

我想改变宽度

比如说,

<!--[if IE]>
<link href="css/ie.css" rel="stylesheet" type="text/css" />
<![endif]-->

提前谢谢

没有

您可以通过在JS中执行浏览器检测并动态附加脚本/样式来破解它

或者,如果您只关心为不同的浏览器使用不同的css,您可以使用css黑客。可能有一些css黑客可以使用您需要的浏览器

或者,如果您只需要更改“宽度”(一个css定义的宽度?),您可能可以在jquery或javascript中进行更改

jquery浏览器检测。见:

我在每个项目中都使用此选项:

尽管如此,如果您必须在Firefox或Webkit中进行大量目标定位,您可能需要重新考虑如何编写HTML/CSS。


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Browsser Detection</title>

<link rel="stylesheet" href="Main.css" type="text/css">

<?php 

$msie        = strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') ? true : false; 
$firefox    = strpos($_SERVER["HTTP_USER_AGENT"], 'Firefox') ? true : false;
$safari        = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari') ? true : false;
$chrome        = strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome') ? true : false;

if ($msie) {
echo '
<!--[if IE 7]>
<link rel="stylesheet" href="ie7.css" type="text/css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" href="ie8.css" type="text/css">
<![endif]-->
';
}
if ($safari) {
echo '<link rel="stylesheet" href="safari.css" type="text/css">';
}

?>

</head>
<body>

    <br>
    <?php
    if ($firefox) { //Firefox?
    echo 'you are using Firefox!';
    }

    if ($safari || $chrome) { // Safari?
    echo 'you are using a webkit powered browser';
    }

    if (!$msie) { // Not IE?
    echo '<br>you are not using Internet Explorer<br>';
    }
    if ($msie) { // IE?
    echo '<br>you are using Internet Explorer<br>';
    }
    ?>

    <br>

</body>
</html>
Browsser检测


中,答案是基于CSS的解决方案。而且它对其他webkit浏览器的支持非常广泛。

IE的条件注释是HTML注释而不是CSS注释。你说得很对。是的。请尝试$.browser.msie==true。$。browser.mozilla==true等。检查$.brower对象或阅读文档在阅读您的回复后,我发现这一点,它运行良好。谢谢但如果我使用电子邮件模板并想检测iPhone?我不能使用脚本。有没有办法隐藏或显示一些专为iPhone设计的html标记?