0

当我第一次加载页面时:不显示任何图片。当我加载页面第二/第三/等时...:所有图片显示。

我做错了什么?

<br style="clear:left;">
<div style="padding-top:48px; padding-bottom:48px; background-color: #1D1626;">
    <div id="gallery-container" style="width:828px; margin-left:auto; margin-right:auto;">
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/56-teszt-1.jpg">
                <img src="/gallery/tgn/example/56-teszt-1.jpg" alt="" name="#capty-id-56" class="gallery-picture">
            </a>
            <div id="capty-id-56">Teszt1</div>
        </div>
        <div class="gallery-item row1">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/55-teszt-2.jpg">
                <img src="/gallery/tgbs/example/55-teszt-2.jpg" alt="" name="#capty-id-55" class="gallery-picture">
            </a>
            <div id="capty-id-55">Teszt2</div>
        </div>
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/54-teszt-3.jpg">
                <img src="/gallery/tgn/example/54-teszt-3.jpg" alt="" name="#capty-id-54" class="gallery-picture">
            </a>
            <div id="capty-id-54">Teszt3</div>
        </div>
    </div>
</div>
<script>
    $(function() {
        var $container = $('#gallery-container');
        $container.imagesLoaded(function() {
            $container.masonry({
                itemSelector : '.gallery-item',
                columnWidth : 276
            });
        });
    });
</script>

http://masonry.desandro.com/demos/images.html#content

人工插件

图片加载插件

MyTest 页面: http: //mansonry-imagesloaded-test.darkrpg.hu/

4

1 回答 1

1

为我工作,请参阅 jsfiddle http://jsfiddle.net/zYqht/

   <div style="background-color:#ee6;">
    <div id="gallery-container">
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/56-teszt-1.jpg">
                <img src="http://lorempixel.com/226/188/?227" alt="" name="#capty-id-56" class="gallery-picture">
            </a>
            <div id="capty-id-56">Teszt1</div>
        </div>
        <div class="gallery-item row1">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/55-teszt-2.jpg">
                <img src="http://lorempixel.com/400/188/?217" alt="" name="#capty-id-55" class="gallery-picture">
            </a>
            <div id="capty-id-55">Teszt2</div>
        </div>
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/54-teszt-3.jpg">
                <img src="http://lorempixel.com/226/188/?222" alt="" name="#capty-id-54" class="gallery-picture">
            </a>
            <div id="capty-id-54">Teszt3</div>
        </div>
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/54-teszt-3.jpg">
                <img src="http://lorempixel.com/226/100/?222" alt="" name="#capty-id-54" class="gallery-picture">
            </a>
            <div id="capty-id-54">Teszt3</div>
        </div>
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/54-teszt-3.jpg">
                <img src="http://lorempixel.com/123/188/?222" alt="" name="#capty-id-54" class="gallery-picture">
            </a>
            <div id="capty-id-54">Teszt3</div>
        </div>
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/54-teszt-3.jpg">
                <img src="http://lorempixel.com/226/321/?222" alt="" name="#capty-id-54" class="gallery-picture">
            </a>
            <div id="capty-id-54">Teszt3</div>
        </div>
        <div class="gallery-item">
            <a rel="prettyPhoto[gallery]" href="/gallery/example/54-teszt-3.jpg">
                <img src="http://lorempixel.com/226/188/?222" alt="" name="#capty-id-54" class="gallery-picture">
            </a>
            <div id="capty-id-54">Teszt3</div>
        </div>      
    </div>
</div>
<script>
    $(function() {
        var $container = $('#gallery-container');
        $container.imagesLoaded(function() {
            $container.masonry({
                itemSelector : '.gallery-item',
            });
        });
    });
</script>
于 2013-07-24T18:27:52.730 回答