2013-12-09 126 views
0

我正在使用演示Bootstrap Lightbox,我也是網絡開發新手。 我無法使燈箱工作,在這種情況下,第一個圖像是可見的,這顯然是一個鏈接,但是當我點擊它時,唯一顯着的變化是網址從http://127.0.0.1:52595/index.html變爲http://127.0.0.1:52595/index.html#demoLightbox,但頁面停留一樣。任何人都可以解釋發生了什麼或不發生什麼?Bootstrap燈箱不彈出

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Bootstrap 101 Template</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <!-- Bootstrap --> 
     <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> 
     <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.css"> 
     <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.js"> 
    <!-- 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.3.0/respond.min.js"></script> 
    <![endif]--> 
    </head> 
    <body> 
    <a data-toggle="lightbox" href="#demoLightbox" class="thumbnail"> 
     <img src="shell_small.jpg" alt="Click to view the lightbox"> 
    </a> 
    <div id="demoLightbox" class="lightbox hide fade" tabindex="-1" role="dialog" aria-hidden="true"> 
     <div class='lightbox-content'> 
      <img src="image.png"> 
      <div class="lightbox-caption"><p>Your caption here</p></div> 
     </div> 
    </div> 

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="https://code.jquery.com/jquery.js"></script> 
    <!-- Include all compiled plugins (below), or include individual files as needed --> 
    <script src="js/bootstrap.min.js"></script> 
    </body> 
</html> 

回答

2

問題是你在jQuery之前加載Lightbox插件。將jQuery放在頭部或jQuery代碼之後的lightbox代碼中。其次,您正在將lightbox代碼作爲樣式表加載。

做這樣的:

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="https://code.jquery.com/jquery.js"></script> 
    <!-- Include all compiled plugins (below), or include individual files as needed --> 
    <script src="js/bootstrap.min.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.js"></script> 
    </body> 
</html> 

,並從頭上摘下

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.js"> 

+0

那麼這些都是很好的改變,但它看起來並沒有改變任何東西 – EasilyBaffled

+0

你是否看到控制檯中的任何錯誤消息? – idmean

+1

您是否在服務器上測試此文件?如果沒有,則必須將'//cdnjs.cloudflare.com/ajax/libs/bootst...'更改爲'http://cdnjs.cloudflare.com/ajax/libs/bootst ...' – idmean