简体   繁体   English

使用JQuery Lightbox的图库

[英]Image Gallery with JQuery Lightbox

I've used the JQuery lightbox on a couple of websites, by having a gallery of thumbnails and the thumbnails as links to the bigger photos. 我在几个网站上使用了JQuery灯箱,通过缩略图库和缩略图作为更大照片的链接。

My question is, using lightbox - can I make it so that I have a thumbnail image that when clicked takes you to a folder with a few pictures to cycle through, rather than just linking to one photo like below? 我的问题是,使用灯箱 - 我可以制作它,以便我有一个缩略图像,当点击时带你到一个文件夹与几张图片循环,而不是只链接到下面的一张照片?

<a href="Images/Gallery/Box1.jpg" class="lightbox">
            <asp:Image runat="server" ImageUrl="~/Images/Box1.jpg" Width="120" Height="88"/>
</a>

In the gallery folder there are two images - Box1.jpg and Box2.jpg, but I only want a link to Box1.jpg on the page and still be able to flick through box images using lightbox. 在gallery文件夹中有两个图像 - Box1.jpg和Box2.jpg,但我只想在页面上找到Box1.jpg的链接,并且仍然可以使用灯箱浏览框图像。

I am using this lightbox: http://leandrovieira.com/projects/jquery/lightbox/ 我正在使用这个灯箱: http//leandrovieira.com/projects/jquery/lightbox/

Is this possible? 这可能吗?

The easiest way to show only one link that opens the lightbox and have the lightbox show multiple images would be to include links for all images in the page and use CSS to hide the unwanted links. 仅显示一个打开灯箱并让灯箱显示多个图像的链接的最简单方法是包含页面中所有图像的链接,并使用CSS隐藏不需要的链接。

Something like this: 像这样的东西:

HTML: HTML:

<ul id="gallery">
    <li class="show"><a href="Box1.jpg"><img src="Box1thumb.jpg" alt="" /></a></li>
    <li><a href="Box2.jpg"><img src="Box2thumb.jpg" alt="" /></a></li>
    <li><a href="Box3.jpg"><img src="Box3thumb.jpg" alt="" /></a></li>
</ul>

CSS: CSS:

#gallery li {
    display: none;
}
#gallery li.show {
    display: block;
}

JavaScript: JavaScript的:

$('#gallery a').lightBox();

For a gallery, you need to give all links the same "rel" attribute, eg: 对于图库,您需要为所有链接指定相同的“rel”属性,例如:

<a href="Images/Gallery/1.jpg" class="lightbox" rel="gallery">
            <img src="Images/Gallery/Thumbnails/1T.jpg" width="136" height="97" />
</a>
<a href="Images/Gallery/2.jpg" class="lightbox" rel="gallery">
            <img src="Images/Gallery/Thumbnails/2T.jpg" width="136" height="97" />
</a>

This is for Fancybox anyway, I'm sure most other plugins work the same. 无论如何,这是为Fancybox,我敢肯定大多数其他插件的工作方式相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM