Fancybox: problems with opacity

浪子不回头ぞ 提交于 2019-12-25 02:28:19

问题


am I right that the following syntax/code doesn't work (anymore)?

$(".fancybox").fancybox({
    helpers : {
        overlay : {
            opacity : 0.9,
            css : {
                'background-color' : '#f00' 
            }
        }
    }
});

check it out: http://jsfiddle.net/jRsjK/3375/

... but only this?

$(".fancybox").fancybox({
    helpers : {
        overlay : {
            css : {
                'background-color' : 'rgba(255, 0, 0, .9)'
            }
        }
    }
});

check it out: http://jsfiddle.net/jRsjK/3374/


回答1:


If you are using the format rgba(255, 0, 0, .9) then the css property should be background, not background-color as in your example code above. Then your script should look like :

$(".fancybox").fancybox({
    helpers : {
        overlay : {
            css : {
                'background' : 'rgba(255, 0, 0, .9)'
            }
        }
    }
});

... see JSFIDDLE (I set a lower opacity value to make it more obvious)

Bear in mind that if you don't set any background property, fancybox will use a semitransparent .png image as background (fancybox_sprite.png). If you set the background-color property (as in your examples above), the png sprite still will be used and may affect the opacity effect you are looking for.

It seems like the opacity API option for the overlay was removed since version 2.1.x (last used was v2.0.6)



来源:https://stackoverflow.com/questions/15090795/fancybox-problems-with-opacity

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