图片库加载帮助/触发后如何动态加载图像?
我有一个与此类似的画廊 JulienPons 。一切正常,但当我加载页面时,加载时间会很长。全屏图像在缩略图和 div 元素之前加载。如何使图像和视频仅在单击缩略图后加载?
附:我使用 href 值来分配图像滑块 div,然后使用 .toggle() 更改每个缩略图的滑块 #。
更新
<div id="featured">
<!-- PROJECT START --><div id="dubstep" class="project">
<ul>
<li class="img1"><img src="gallery/dubstep-1.jpg" alt="Css Template Preview" width="940" height="529"/></li>
<li class="img2"><img src="gallery/dubstep-2.jpg" alt="Css Template Preview" width="940" height="529"/></li>
<li class="img3"><img src="gallery/dubstep-1.jpg" alt="Css Template Preview" width="940" height="529"/></li>
<li class="iframe"><img src="gallery/dubstep-1.jpg" alt="Css Template Preview" width="940" height="529"/></li>
</ul>
</div><!-- PROJECT END -->
</div>
我希望这些图像仅在我单击带有类拇指的 div 后加载。他们现在的方式是加载文档,导致加载时间非常长。
<div id="portfolio">
<div id="thumbnails">
<!--THUMBNAIL START --><div class="thumb" id="dubstep-thumb"><a href="#dubstep">
<img src="thumbs/dubstep-bwthumb.jpg" alt="" width="300" height="169"/>
</div><!--THUMBNAIL END -->
</div>
</div>
I have a gallery similar to this one JulienPons . Everything works fine but when I load the page, it gets massive loading times. The fullscreen images load before the thumbnails and div elements. How can I make the images and videos load only after the thumbnail is clicked?
ps. I use the href value to assign the image slider div, then use .toggle() to change the slider # for each thumbnail.
Update
<div id="featured">
<!-- PROJECT START --><div id="dubstep" class="project">
<ul>
<li class="img1"><img src="gallery/dubstep-1.jpg" alt="Css Template Preview" width="940" height="529"/></li>
<li class="img2"><img src="gallery/dubstep-2.jpg" alt="Css Template Preview" width="940" height="529"/></li>
<li class="img3"><img src="gallery/dubstep-1.jpg" alt="Css Template Preview" width="940" height="529"/></li>
<li class="iframe"><img src="gallery/dubstep-1.jpg" alt="Css Template Preview" width="940" height="529"/></li>
</ul>
</div><!-- PROJECT END -->
</div>
I want these images to load only after I click the div with the class thumb. The way they are now, they load with the document, making the loading times really big.
<div id="portfolio">
<div id="thumbnails">
<!--THUMBNAIL START --><div class="thumb" id="dubstep-thumb"><a href="#dubstep">
<img src="thumbs/dubstep-bwthumb.jpg" alt="" width="300" height="169"/>
</div><!--THUMBNAIL END -->
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为每个图像提供一个 id,并将它们的 src 设置为一个小的 1x1 dummy.gif:
将 onclick 属性添加到您的拇指 div:
在
中定义 loadImage(),如下所示:
give an id to each of your images and set their src to a small 1x1 dummy.gif:
add onclick attribute to your thumb div:
define loadImage() in your
<head>
like this: