Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Opacity in CSS For Chrome

I've tried the following:

(this is actually for fancybox, as the overlay does not show in chrome/safari:

   $("#fancy_overlay").css({<br />
                    'background-color': opts.overlayColor,<br />
                    'opacity': opts.overlayOpacity,<br />
                    '-moz-opacity': opts.overlayOpacity,<br />
                    '-khtml-opacity': opts.overlayOpacity,<br />
                    '-webkit-opacity:' : opts.overlayOpacity<br />
    }).show();

And still nothing (in chrome/safari)

What am I doing wrong?

like image 494
dell Avatar asked Dec 18 '22 04:12

dell


1 Answers

opacity should work for chrome/safari/firefox. The -moz and -khtml syntaxes are only used to support the much older versions of these browsers.

I've never run across the -webkit-opacity style before and can't seem to find any documentation that says it exists. I would try removing it entirely or fixing the syntax bug you have in there: '-webkit-opacity:' to '-webkit-opacity' (without the trailing colon).

If that doesn't work try printing the value of opts.overlayOpacity. Make sure it's something like 0.5 and not 50 or 50%.

like image 153
Chris Van Opstal Avatar answered Dec 19 '22 20:12

Chris Van Opstal