简体   繁体   中英

Magnific popup not working properly

Magnific popup is working, but not the way I want it to.

Here is Plnkr .

Why is it not working? Here is the jQuery code:

$('.view').click(function() {
    $('.image-popup').magnificPopup({
        type: 'image',
        closeOnContentClick: true,
        mainClass: 'mfp-img-mobile',
        image: {
            verticalFit: true
        }
    });
});

Why don't you change your html to :

<div class="pic">
    <a  class="image-popup-fit-width" href="http://farm4.staticflickr.cm/3721/9207329484_ba28755ec4_o.jpg" title="This image fits only horizontally.">
    <img src="pictureLink" width="75" height="75">
  </a>
  <p><a href="http://farm4.staticflickr.com/3721/9207329484_ba28755ec4_o.jpg" class="image-popup-fit-width">Click to view</a></p>
  </div>

The anchor tag needs to have image-popup-fit-width class rather image-popup.

<a  class="image-popup-fit-width" href="http://farm4.staticflickr.com/3721/9207329484_ba28755ec4_o.jpg" title="This image fits only horizontally.">
        <img src="http://farm4.staticflickr.com/3721/9207329484_ba28755ec4_o.jpg" width="75" height="75">
</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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