1

So I've had no problem getting Masonry to work when initializing in HTML, but since there is no way to implement the "imagesLoaded" without writing a little Javascript, I've decided to try and rework the site to initialize using jQuery.

<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script src="masonry/masonry.pkgd.min.js"></script>
<script src="imagesloaded/imagesloaded.js"></script>

<script type="text/javascript">
$(document).ready(function() 
 {
    $('#portfoliocontent').masonry
     ({
         columnWidth: 255,
         itemSelector: '.item1'
        ).imagesLoaded(function() {
            $('#portfoliocontent').masonry('reload');
          });
      });
  });
</script>

</head>

<body>
<div id="portfoliocontent">
<div class="item1"><img src="images/masonthumb1.jpg"></div>
<div class="item1"><img src="images/masonthumb1.jpg"></div>
<div class="item1"><img src="images/masonthumb1.jpg"></div>
<div class="item1"><img src="images/masonthumb1.jpg"></div>
</div>
</body>

The reason I'm reworking at all is because of the images stacking on load, and now I can't even get Masonry to initialize at all. I'm not the most familiar with Javascript or jQuery, so any help is appreciated. Thanks.

4

0 回答 0