2

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]-->
Rich
  • 5,603
  • 9
  • 39
  • 61
yuli chika
  • 9,053
  • 20
  • 75
  • 122

2 Answers2

6

Conditional comments are recognized by IE only. If you need Opera-specific CSS, you will need JavaScript:

if (window.opera) {
    document.getElementById('foo').style.height = '100px';
}
jwueller
  • 30,582
  • 4
  • 66
  • 70
3

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;}}

Sotiris
  • 38,986
  • 11
  • 53
  • 85