2

I'm using the jQuery Isotope plugin, and although I have it working, I can't seem to get it to recognise any margins.

I can see in Firebug that the margins are being applied, but the items are just overlapping the margin (I think becasuse isotope uses absolute positioning).

I had the width working briefly by using the following:

masonry : {
columnWidth : 172
          }

but I couldn't figure out how to get the height working (I tried rowHeight with masonry, and masonryHorizontal).

How do I tell isotope what widths, and heights to use?

Thanks

4

3 回答 3

1

The problem is probably that Isotope is doing its thing before the images are loaded. Use this code:

var $container = $('#container');

$container.imagesLoaded(function() {
  $container.isotope({
    // options...
  });
});
于 2013-02-08T15:51:08.047 回答
1

尝试使用此代码:

$(window).load() instead of $(document).ready()
于 2011-08-01T09:42:21.007 回答
0

我遇到了类似(如果不相同)的问题;我的物品之间没有垂直间距。确保在平铺元素上包含以下 CSS 属性:

.element {
  width: 110px; /*your columnWidth minus 10px */
  height: 110px; /*same as width, for a square grid system*/
  margin: 5px; /*5px here will result in 10px of vertical spacing between tiles*/
  float: left;
  overflow: hidden;
  position: relative;
}

希望这可以帮助。

于 2011-08-18T03:52:07.417 回答