简体   繁体   English

放大弹出式窗口不起作用

[英]Magnific-Popup Not Working

I want to implement the magnific popup on my website, I followed all the instructions in the documentation, but nothing happened. 我想在我的网站上实现宏伟的弹出窗口,我按照文档中的所有说明进行了操作,但是没有任何反应。

here are the header files I included. 这是我包含的头文件。

<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="magnific-popup/magnific-popup.css">

<!-- jQuery 1.7.2+ or Zepto.js 1.0+ -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js" type="text/javascript"></script>

<!-- Magnific Popup core JS file -->
<script src="magnific-popup/jquery.magnific-popup.js"></script>
<script src="magnific-popup/jquery.magnific-popup.min.js"></script> 

This is my initialization code. 这是我的初始化代码。

<script src="js/magnificpopinit.js"></script> (at the end of index.html within body)

$(document).ready(function() {
$('.portfolio-img').magnificPopup({
    delegate: 'a',
    type:'image'
   });
});  

and my code is 我的代码是

<div class=" col-xs-offset-1"> 
   <div class=" twelve columns container">           
          <div data-anim-type="fadeInUp" class="setwidth25 animate fadeInUp">
                    <div class="box"> <a class=" portfolio-img"  href="Website/Community Service/Aug 15 Plantation/20840999_1763381930619812_5996646119960337765_n.jpg"><img alt="plantation" BORDER="0" src="Website/Community Service/Aug 15 Plantation/20840999_1763381930619812_5996646119960337765_n.jpg" height="200" width="200"> </a></div>
         </div>
         <div data-anim-type="fadeInUp" class=" setwidth25 animate fadeInUp">
                    <div class="box"> <a class="portfolio-img"  href="Website/Community Service/Aug 15 Plantation/20840999_1763381930619812_5996646119960337765_n.jpg"><img alt="plantation" src="Website/Community Service/Aug 15 Plantation/20841080_1763381967286475_679893694361630086_n.jpg" height="200" width="200"> </a></div>
         </div>
         <div data-anim-type="fadeInUp" class=" setwidth25 animate fadeInUp">
                    <div class="box"> <a class="portfolio-img" href="Website/Community Service/Aug 15 Plantation/20840999_1763381930619812_5996646119960337765_n.jpg"><img alt="plantation" src="Website/Community Service/Aug 15 Plantation/20914365_1763382237286448_3724536977546091967_n.jpg" height="200" width="200"> </a></div>
         </div>
         <div data-anim-type="fadeInUp" class=" setwidth25 animate fadeInUp">
                    <div class="box"> <a class="portfolio-img" href="Website/Community Service/Aug 15 Plantation/20840999_1763381930619812_5996646119960337765_n.jpg"><img alt="plantation" src="Website/Community Service/Aug 15 Plantation/20953405_1763381833953155_7689290877386847638_n.jpg" height="200" width="200"> </a></div>
         </div>
   </div>
</div>

Console shows no error related to magnific popup,yet it is not working. 控制台未显示与放大弹出框相关的错误,但无法正常工作。 I searched many related articles but none of them worked. 我搜索了许多相关文章,但没有一个起作用。 I'm banging my head with this for more than 6 hours. 我为此努力了6个多小时。 Is there any problem with my code. 我的代码有什么问题吗? How do I make it work? 我该如何运作? Please help!!... Thanks in advance. 请帮忙!! ...在此先感谢。

replace this block of code in your code. 将此代码块替换为您的代码。 And make sure your jquery and js path is correct. 并确保您的jquery和js路径正确。 you used multiple jquery and magnific js that's not necessary. 您使用了不必要的多个jquery和华丽的js。 remove it and try only two script file that i include here. 删除它,然后尝试仅在此处包含的两个脚本文件。 i used it from cdn. 我从CDN使用它。 It works here fine. 它在这里工作正常。 Hope that will help you. 希望对您有所帮助。

 $('.portfolio-img').magnificPopup({ type: 'image', closeOnContentClick: true, image: { verticalFit: false } }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script> 

Seems that you have not wrapped JavaScript code inside <script></script> tags: 似乎您没有将JavaScript代码包装在<script></script>标记内:

<script src="js/magnificpopinit.js"></script> (at the end of index.html within body)

$(document).ready(function() {
$('.portfolio-img').magnificPopup({
    delegate: 'a',
    type:'image'
   });
});  

It probably should be: 可能应该是:

<script src="js/magnificpopinit.js"></script> (at the end of index.html within body)

<script>
    $(document).ready(function() {
        $('.portfolio-img').magnificPopup({
            delegate: 'a',
            type:'image'
        });
    });  
</script>

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

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