如何制作CSS“if opera,not...”
我想制定一个css规则,它影响除opera浏览器之外的所有浏览器,所有其他浏览器都添加一个css规则:
#content{left:1px;}
,(opera没有此规则)。下面的代码不起作用...
<!--[if !OPERA]>
<style type="text/css">
#content{left:1px;}
</style>
<![endif]-->
I want to make a css rule, which affects all but the opera browser, all the other browser add a css rule:
#content{left:1px;}
, (opera without this rule). the below code not worked...
<!--[if !OPERA]>
<style type="text/css">
#content{left:1px;}
</style>
<![endif]-->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
条件注释仅被 IE 识别。如果您需要 Opera 特定的 CSS,您将需要 JavaScript:
Conditional comments are recognized by IE only. If you need Opera-specific CSS, you will need JavaScript:
您可以使用您想要的选择器属性,例如
#content{left:1px;}
,然后为 opera 添加 css hack,提供默认值(或您想要的值)。 css hack 具有以下语法:@media all and (min-width:0px) {head~body .selector {property:value;}}
前面语法的示例,您的示例可以是:@media all 和 (min-width:0px) {head~body #content {left:0px;}}
you can use the property you want for a selector like
#content{left:1px;}
then add a css hack for opera providing the default value (or the value you want). The css hack has the following syntax:@media all and (min-width:0px) {head~body .selector {property:value;}}
an example of the previous syntax and your example could be:@media all and (min-width:0px) {head~body #content {left:0px;}}