简体   繁体   English

fancybox内的Fancybox(或嵌套的fancybox)

[英]Fancybox inside fancybox( or nested fancybox)

I have three html pages, index.html, first.html and second.html. 我有三个html页面,index.html,first.html和second.html。 In index page I have a button B1. 在索引页面中,我有一个按钮B1。 When I clicked on that button a fancy box is opened with contents of first.html. 当我单击该按钮时,将打开一个包含first.html内容的精美框。 Inside fancybox , another button B2 is used. 在fancybox内部,使用了另一个按钮B2。 When B2 is clicked , second fancybox is open. 单击B2时,第二个花式框打开。 2nd fancy box is inside of first fancybox and the content of 2nd is second.html. 第二个花式框位于第一个花式框的内部,第二个花式框的内容为second.html。 The problem is size of 2nd fancybox is limiting inside of first fancybox. 问题是第二个fancybox的大小限制在第一个fancybox的内部。 How can I increase the width and height of 2nd fancybox than that of 1st fancybox? 我怎样才能增加第二个fancybox的宽度和高度? Following is the code. 以下是代码。

$(".fancybox").click(function () {
        var url = $(this).attr('url');
        $.fancybox.open({
            href: url,
            type: 'iframe',
            padding: 1,
            autoDimensions: true,
            autoScale: false,
        });
    });

I tried to set width and height but not worked. 我试图设置宽度和高度,但没有用。

您可以添加到按钮中,以打开第二个花式框:

onclick="parent.window.document.getElementById('fancybox-wrap').style.width = '1000px';parent.window.document.getElementById('fancybox-wrap').style.height= '1000px'"

According to the documentation if you set "autoDimensions" to true, the width and height parameters are ignored. 根据文档,如果将“ autoDimensions”设置为true,则会忽略width和height参数。

Have you tried to set "margin" equal to 0? 您是否尝试将“保证金”设置为0? It will remove the space between the box and the viewport. 它将删除框和视口之间的空间。

Take a look on this example: http://codepen.io/thiagofelix/pen/MYjNKE 看一下这个例子: http : //codepen.io/thiagofelix/pen/MYjNKE

$(document).ready(function () {
  $.fancybox({
    href: 'http://i.imgur.com/u0FXwTf.jpg',
    link: 'http://www.google.com.br',
    margin: 0,
    padding: 0,
    showCloseButton: false
  });
});

You can use function onComplete then update height of your modal 您可以使用onComplete函数,然后更新模态的高度

    $(".fancybox").click(function () {
            var url = $(this).attr('url');
            $.fancybox.open({
                href: url,
                type: 'iframe',
                padding: 1,
                autoDimensions: true,
                autoScale: false,
                onComplete: function(){
                    $('#fancybox-frame').bind('load',function(obj){
                            $('#fancybox-content').height(this.contentWindow.document.body.scrollHeight) // detect height of our frame and set it to modal
                            $.fancybox.resize();//auto resize
                    });
                }
            });
        });

This is a DEMO 这是一个演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM