花式框内的内容需要响应

时间:2015-10-06 15:50:28

标签: javascript jquery html css responsive-design

我想创建一个位于精美框中的图库,所以首先我下载了​​图库的所有内容并附加到html容器中。

<div id="popup" style="display:none;"><div class="galleria"></div></div>

jquery部分

$("#hidden_content").instagram({
        clientId: blockInstaSettings.clientId
        , hash: hash
        , userId: blockInstaSettings.userId
        , next_url: insta_next_url
        , show: 10
        , image_size: image_size
        , onComplete: function (photos, data) {
            var album_html = "";

            $.each(photos, function( index, val ) {
                album_html += "<img src='" + val.images.standard_resolution.url + "' data-title='' data-description='" + val.caption.text.replace("'","&rsquo;") + "' longdesc='" + val.link + "'>";
            });

            $(".galleria").html(album_html);

                $('#block_instagram').on('click', function () {
                    openPop();
                    return false;
                });
        }
    });

请注意,我在显示fancybox的按钮中设置了侦听器

function openPop(){
    $.fancybox({
         'autoScale': true,
         'transitionIn': 'elastic',
         'transitionOut': 'elastic',
         'speedIn': 500,
         'speedOut': 300,
         'autoDimensions': true,
         'centerOnScroll': true,
         'href' : '#popup'
    });

    Galleria.run('.galleria', {
        transition: 'fade',
        popupLinks: true,
        show: no,
        extend: function(options) {
            Galleria.get(0).$('info-link').click();
        }
    });
}

在fancybox的galleria.run事件时尝试致电afterShow;但它仍然是一样的。

对于CSS,它必须是:

.galleria{
    width:700px;
    height:500px;
}

否则,它无法生成图库

如何解决这个问题?

参考

我的网站: http://internal001.zizsoft.com/be_pure/

(当你滚动到底部时,有一个滑块显示instagram照片,点击照片,你会看到画廊)

使用的插件:

http://galleria.io/

http://fancyapps.com/fancybox/

4 个答案:

答案 0 :(得分:11)

正如其他人在commants中提到的那样,你使用的所有插件都已经响应了。当我访问你的网站,如果我在打开fancybox后调整窗口大小,它的大小不会定义为“响应”。我以为这是你在担心的事情。您可以通过在窗口大小调整事件上调整大小的galleria来调用它。请参考此resize script for galleria来实现。感谢

更新(来自推荐链接的基本代码块)
在窗口调整大小时重新初始化广场。

首先,设置调整大小功能:

function ResizeGallery() {
     gWidth = $(window).width();
     gHeight = $(window).height();
     gWidth = gWidth - ((gWidth > 200) ? 100 : 0);
     gHeight = gHeight - ((gHeight > 100) ? 50 : 0);
     $("#gallerycontainer").width(gWidth);
     $("#gallery").width(gWidth);
     $("#gallery").height(gHeight);
     // Reload theme
     Galleria.loadTheme('js/galleria/themes/classic/galleria.classic.js', { show: curIdx });
}

然后将其绑定到窗口调整大小事件:

var TO = false;
$(window).resize(function () {
    if (TO !== false)
        clearTimeout(TO);
    TO = setTimeout(ResizeGallery, 200); //200 is time in miliseconds
});

这将基本上通过重新加载默认主题来重新初始化。在这个例子中,我使用第二个参数来指定要显示的图像 - 否则它将显示第一个图像。请注意,这可能会导致另一个Galleria实例。我相信这是一个错误,并发布在他们的论坛上。您可以按如下方式删除旧实例:

var gcount = Galleria.get().length;

if (gcount > 1) {
   Galleria.get().splice(0, gcount - 1);
}

在loadTheme方法之后运行它。使用settimeout来延迟它,因为loadTheme需要一些时间才能完成。我用200ms。丑陋,但我需要Galleria的一些功能。希望这会有所帮助。

答案 1 :(得分:2)

每件事都是敏感的并且运作良好。详细说明你的问题。

如果您希望弹出窗口缩略图出现在弹出窗口的中间,请使用以下代码

.galleria-thumbnails {
text-align: center;
width: 100% !important;

    }



.galleria-image {

    display: inline-block;

    float: none !important;

    }

答案 2 :(得分:1)

我发现使用javascript处理最适合我的方法你可以让你的脚本计算高度,然后在你初始化fancybox的地方做这样的事情

fitToView : true,
autoSize  : true,
width     : 100%,
height    : 'auto',

你可以使用fitToView和autoSize,直到你获得所需的效果,就像pinterest一样

答案 3 :(得分:0)

你可以用一个简单的css技巧来做到这一点。

在响应媒体屏幕中,您必须将CSS设置为

.tp-simpleresponsive .slotholder *, .tp-simpleresponsive img { background-size: 100% auto !important; }

enter image description here