jquery masonry collapsing on initial page load, works fine after clicking “home” menu button

前端 未结 2 1442
有刺的猬
有刺的猬 2021-02-06 08:57

My jquery masonry setup is working strangely on initial page load. It seems to be placing the images in the first row fine, the second row is positioned overlapping the first an

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 09:15

    I think it's because the script is being run before the content (images) is fully loaded. Hence the positioning error.

    Try this.

      $(window).load(function()
      {
          $('#content').masonry({
               itemSelector : '.product',
               columnWidth : 310,
               isAnimated: true,
               animationOptions: {
                    duration: 700,
                    easing: 'linear',
                    queue: false
               }
          });
      });
    

提交回复
热议问题