Setting Opacity in CSS For Chrome

邮差的信 提交于 2019-12-10 15:21:09

问题


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?


回答1:


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%.



来源:https://stackoverflow.com/questions/1757425/setting-opacity-in-css-for-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!