lightgallery markup带有对齐图像网格的问题

时间:2015-12-05 03:15:30

标签: jquery html lightbox lightgallery

您好我在使用JIG画廊实施lightgalley灯箱时遇到了麻烦。 JIG生成的库代码如下所示:

HTML

<div id="jig2" class="justified-image-grid jig-eec93aceb26f618c747e9fe2abded7ce jig-preset-c1" style="width: 1278px;">
  <div class="jig-imageContainer jig-contentID-ML-1191">
    <div class="jig-overflow" style="opacity: 1; width: 658px; height: 438px;">
      <a class="jig-link lulz jig-loaded" rel="jig[2]" test="lala" href="http://127.0.0.1/wp/wp-content/uploads/2014/11/untitled-imgp1913.jpg">
        <img src="http://127.0.0.1/wp/wp-content/plugins/justified-image-grid/timthumb.php?src=http%3A%2F%2F127.0.0.1%2Fwp%2Fwp-content%2Fuploads%2F2014%2F11%2Funtitled-imgp1913.jpg&amp;h=1040&amp;w=1560&amp;q=45&amp;f=.jpg" width="658" height="439" style="width: 658px; height: 439px; margin-top: 0px;"></a>
      </div>
    </div>
    <div class="jig-imageContainer jig-contentID-ML-1190 jig-last">
      <div class="jig-overflow" style="opacity: 1; width: 614px; height: 438px;">
        <a class="jig-link lulz jig-loaded" rel="jig[2]" test="lala" href="http://127.0.0.1/wp/wp-content/uploads/2014/11/untitled-imgp1912.jpg">
          <img src="http://127.0.0.1/wp/wp-content/plugins/justified-image-grid/timthumb.php?src=http%3A%2F%2F127.0.0.1%2Fwp%2Fwp-content%2Fuploads%2F2014%2F11%2Funtitled-imgp1912.jpg&amp;h=1040&amp;w=1456&amp;q=45&amp;f=.jpg" width="614" height="439" style="width: 614px; height: 439px; margin-top: 0px;"></a>
        </div>
      </div>
      <div class="jig-imageContainer jig-contentID-ML-1192 jig-last">
        <div class="jig-overflow" style="opacity: 1; width: 634px; height: 448px;">
          <a class="jig-link lulz jig-loaded" rel="jig[2]" test="lala" href="http://127.0.0.1/wp/wp-content/uploads/2014/11/untitled-imgp1915.jpg">
            <img src="http://127.0.0.1/wp/wp-content/plugins/justified-image-grid/timthumb.php?src=http%3A%2F%2F127.0.0.1%2Fwp%2Fwp-content%2Fuploads%2F2014%2F11%2Funtitled-imgp1915.jpg&amp;h=1040&amp;w=1472&amp;q=45&amp;f=.jpg" width="634" height="448" style="width: 634px; height: 448px; margin-top: 0px;"></a>
          </div>
        </div>

遵循指南(http://sachinchoolur.github.io/lightGallery/demos/html-markup.html),我尝试了以下代码但没有成功。当我点击图库项目时,未加载lightgallery:

JS

<script type="text/javascript">
    $(document).ready(function() {
      $('.justified-image-grid').lightGallery({
        selector: '.lulz'
      });
});
</script>


<script type="text/javascript">
      $('.justified-image-grid').lightGallery({
        selector: '.lulz'
      });
</script>

<script type="text/javascript">
      $('.justified-image-grid').lightGallery();
</script>

<script type="text/javascript">
      $('#jig2').lightGallery();
</script>

我可以加载lightgallery,但它不会显示具有此自定义灯箱的JIG默认设置的图像:

<script type="text/javascript">
          $('#jig2 a.jig-link').lightGallery();
</script>

或者在图库中加载单个图片

<script type="text/javascript">
          $('.lulz').lightGallery({
            selector: 'this'
   });
</script>

同样复制演示工作..我上周工作了,但我的编码进度丢失了。所以我知道必须有一个解决方案,我再也找不到了。

2 个答案:

答案 0 :(得分:0)

解决了,我在代码中发现了另一个lightgallery标记,我可能忘了删除它。

现在,此代码在用作jig的自定义灯箱调用时起作用:

$('.justified-image-grid').lightGallery({
selector: '.lulz'
});

$('#jig1').lightGallery({
selector: '.lulz'
});

也有效。但是我只适用于页面上的第一个库,后续即使使用

也不会加载
$('#jig2').lightGallery({
selector: '.lulz'
});

答案 1 :(得分:0)

$(JIG_selector).lightGallery({selector: '.lulz'});

到JIG设置&gt;灯箱标签&gt;自定义灯箱JS调用。