2014-10-27 81 views
0

我正在建设一个网站,并在其中一个页面上展示一些图像。我认为prettyPhoto看起来不错,并决定使用它。在PrettyPhoto中显示多个图像

现在我在引导中有一个方框'box',共有2个col-md-4行(共6个)。每个图像都有一个悬停状态,悬停状态发生变化,显示一个图标点击,并从此处打开prettyPhoto。

我不知道如何给文档添加多张图片到prettyPhoto,但是在他们的文档中有它的例子,我只是没有任何运气来实现它们。

这里是我的代码

HTML

<div class="row centered"> 
      <div class="col-md-4 portfolio-item web-design"> 
      <div class="he-wrap tpl6"> 
       <img src="images/portfolio-2/crate-of-california.jpg" height="450px" width="600px" class="img-responsive" alt=""> 
        <div class="he-view"> 
        <div class="bg a0" data-animate="fadeIn"> 
         <h3 class="a1" data-animate="fadeInDown">Crate of California</h3> 
         <a data-rel="prettyPhoto[gallery1]" href="images/portfolio-2/crate-of-california.jpg" width="600" height="486" class="dmbutton a2" data-animate="fadeInUp"><i class="fa fa-search"></i></a> 
        </div><!-- he bg --> 
       </div><!-- he view -->  
      </div><!-- he wrap --> 
      </div> 

JS

(function($) { 
// prettyPhoto 
    jQuery(document).ready(function(){ 
     jQuery('a[data-gal]').each(function() { 
      jQuery(this).attr('rel', jQuery(this).data('gal')); 
     });  
     jQuery("a[data-rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:false,overlay_gallery: false,social_tools:false,deeplinking:false,allow_resize:true}); 
    });  
})(jQuery); 

如果需要的话,我可以张贴的CSS,但大部分没有任何与问题。

有谁知道我怎么能用prettyPhoto显示每个图像的多个图像(画廊)?任何帮助,将不胜感激。

回答

0

所以我得到了这个想法,该网站上的文档并不是很好,我花了几个小时才弄明白,所以希望有人得到一些用处。

基本上,我试图为我的2x3行中的6个图像中的每一个显示一个图像库。代码结束了;

HTML

<div class="col-md-4 portfolio-item web-design"> 
      <div class="he-wrap tpl6"> 
       <img src="images/portfolio-2/kenneth-cole.jpg" height="450px" width="600px" class="img-responsive" alt=""> 
        <div class="he-view"> 
        <div class="bg a0" data-animate="fadeIn"> 
         <h3 class="a1" data-animate="fadeInDown">Kenneth Cole</h3> 
         <a rel="prettyPhoto[gallery2]" href="images/portfolio-2/kenneth-cole.jpg" class="dmbutton a2" data-animate="fadeInUp"><i class="fa fa-search"></i></a> 
         <a href="images/portfolio-images/kennethcole2.png" class="lightbox-image lightbox-hide" rel="prettyPhoto[gallery2]" title="Another Title 2"></a> 
         <a href="images/portfolio-images/kennethcole3.png" class="lightbox-image lightbox-hide" rel="prettyPhoto[gallery2]" title="Another Title 2"></a> 
         <a href="images/portfolio-images/kennethcole4.png" class="lightbox-image lightbox-hide" rel="prettyPhoto[gallery2]" title="Another Title 2"></a> 
        </div><!-- he bg --> 
       </div><!-- he view -->  
      </div><!-- he wrap --> 
      </div> 



     ..... 
     <!-- beneath your main content, before your closing body tag 
the social tools (twitter and facebook sharing) are in there by default, so this takes it off --> 
     <script type="text/javascript" charset="utf-8"> 
      $(document).ready(function(){ 
       $("a[rel^='prettyPhoto']").prettyPhoto({social_tools:''}); 
      }); 
     </script> 
     </body> 

基本上你只需要确保你的“扳机”是rel=prettyPhoto,你可以在每个格中的多者。 prettyPhoto有助手和按钮,一旦你得到多个图像显示。