2014-09-22 103 views
0

我一直在嘗試2個小時才能讓FancyBox工作並且不知道它是如何工作的。顯然,我錯過了一些東西,因爲它只是鏈接到圖像。FancyBox不會「彈出」

例如:我將圖像鏈接到我的圖像文件夾(包括大拇指和大圖像),當我點擊圖像時,它會將我帶到一個新頁面並向我顯示圖像而不是彈出。

這裏是我的代碼:

<head> 

    <!-- Bootstrap Core CSS --> 
    <link href="css/bootstrap.min.css" rel="stylesheet"> 

    <!-- Custom CSS --> 
    <link href="css/stylish-portfolio.css" rel="stylesheet"> 

    <!-- Custom Fonts --> 
    <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> 
    <link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css"> 

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]> 
     <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> 
     <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> 
    <![endif]--> 

    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> 
    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> 
    <link rel="stylesheet" type="text/css" href="/stylish-portfolio/fancybox/source/jquery.fancybox.css" media="screen"/> 
    <link rel="stylesheet" type="text/css" href="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-thumbs.css" media="screen"/> 
    <link rel="stylesheet" type="text/css" href="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-buttons.css" media="screen"/> 
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.pack.js"></script> 
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.js"></script> 
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-buttons.js"></script> 
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-thumbs.js"></script> 
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-media.js"></script> 



    <script type="text/javascript"> 
     $(document).ready(function() { 
     $(".fancyImg").fancybox(); 
}); 
     </script></head> 


    <div class="row"> 
         <div class="col-md-6"> 
          <div class="portfolio-item"> 
           <a class="fancyImg" href="img/portfolio-2.jpg" title="Lorem ipsum dolor sit amet"><img src="img/portfolio-2.jpg" alt="" /></a> 
          </div> 
         </div> 
+1

任何JS錯誤? – 2014-09-22 16:08:51

+0

您或者需要加載fancybox js文件的正常版本或pack版本,但不能同時加載 – JFK 2014-09-22 17:47:39

回答

0

我首先看到的是你加載的fancybox兩次。選一個。

<script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.pack.js"></script> 
<script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.js"></script> 
0

中HTML主體部分添加此代碼

<a class="fancyImg" href="img1.jpg" title="Lorem ipsum dolor sit amet"><img src="img1.jpg" alt="" /></a> 

     <script type="text/javascript"> 
      $(document).ready(function() { 
       $(".fancyImg").fancybox(); 
        type:"iframe" 
        }); 
     </script> 

而且它似乎是在控制檯做工精細:)

+0

您無需打開圖片作爲iframe圖標 – JFK 2014-09-22 17:46:56

+0

不,您是對的。我在檢查時只添加了一個類型 – 2014-09-22 18:06:09