【问题标题】:Displaying multiple images in PrettyPhoto在 PrettyPhoto 中显示多张图像
【发布时间】:2014-10-27 18:31:05
【问题描述】:

我正在建立一个网站,其中一个页面上有一个展示一些图片的部分。我认为 prettyPhoto 看起来不错,并决定使用它。

现在我在引导程序中有一个方形“盒子”,有 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 在每张图片上显示多张图片(画廊)?任何帮助,将不胜感激。

【问题讨论】:

    标签: javascript html twitter-bootstrap prettyphoto


    【解决方案1】:

    所以我能够弄清楚这一点,该网站上的文档一点也不好,我花了几个小时才弄清楚,所以希望有人能从中得到一些用处。

    基本上,我试图为我的 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,并且每个div可以有多个。一旦出现多张图片,prettyPhoto 就会有助手和按钮。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-29
      • 2019-02-02
      • 2015-04-15
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多