Fancybox - 如何制作开箱即用的黑色东西?

时间:2012-04-12 18:06:22

标签: fancybox

我对Fancybox了解不多,我对所有文件感到困惑。我想我有一个简单的问题,但我似乎无法在网上找到答案。必须如此轻松,没有人问过,或者我不擅长在线搜索。

我正在使用带有iframe的Fancybox,并且想知道我怎么能把那些在fancybox之外的东西全黑?我只希望iframe可见,或者让外面的90%变黑。我会在哪里这样做?在什么档案?文件太多了。

我有另一个问题。如何通过点击任何地方关闭iframe?我记得起初它就是这样,然后我改变了它,只有通过点击X才关闭它。我不记得我修改了什么文件。 :/

谢谢!

2 个答案:

答案 0 :(得分:1)

假设您使用html打开fancybox:

<a href="page.html" class="fancybox">open page</a>

无需修改任何文件,只需将正确的选项( for fancybox v1.3.4 )添加到自定义脚本中,如:

$(".fancybox").fancybox({
 "overlayColor": "#000",  // here you set the background black
 "overlayOpacity": 1,  // here you set the transparency of background: 1 = opaque
 "hideOnOverlayClick": true,  // if true, closes fancybox when clicking OUTSIDE the box
 "hideOnContentClick": true, // if true, closes fancybox when clicking INSIDE the box
 "type": "iframe" // the type of content : iframe for external pages
 "width": 640, // if type=iframe is always smart to set dimensions
 "height": 320
});

请注意,Boolean和/或integer值不应包含引号

其他选项read the documentation

答案 1 :(得分:0)

如果您使用fancybox V2

您可以在此文件中看到:jquery.fancybox.css

查找:

    /* Overlay helper */

#fancybox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    display: none;
    z-index: 1001;
    background: #000;
}

添加:

opacity: 1 !important; 

不透明度是一个双倍值,所以如果你想要90%的不透明度,它是:0.90