Multiple Galleries with Magnific Popup

后端 未结 1 1694
清歌不尽
清歌不尽 2021-02-10 07:41

I\'m trying to create a page with a few galleries using the Magnific-Popup jQuery plug-in. I different sections contained in divs with separate ids and a .gal

相关标签:
1条回答
  • 2021-02-10 08:17

    From the documentation:

    To have multiple galleries on a page, you need to create a new instance of Magnific Popup for each seperate gallery. For example

    <div class="gallery">
        <a href="path-to-image.jpg">Open image 1 (gallery #1)</a>
        <a href="path-to-image.jpg">Open image 2 (gallery #1)</a>
    </div>
    <div class="gallery">
        <a href="path-to-image.jpg">Open image 1 (gallery #2)</a>
        <a href="path-to-image.jpg">Open image 2 (gallery #2)</a>
        <a href="http://vimeo.com/123123" class="mfp-iframe">Open video (gallery #2). Class mfp-iframe forces "iframe" content type on this item.</a> 
    </div>
    

    Javascript

    $('.gallery').each(function() { // the containers for all your galleries
        $(this).magnificPopup({
            delegate: 'a', // the selector for gallery item
            type: 'image',
            gallery: {
              enabled:true
            }
        });
    });
    

    Hope that helps!

    0 讨论(0)
提交回复
热议问题