tga缩略图预览_具有扩展预览的缩略图网格

本文展示了如何在网页上实现类似于Google图片搜索的缩略图预览效果。当用户点击缩略图时,会弹出一个预览窗口,显示较大的图像和相关描述信息。预览窗口的高度会根据页面位置自动调整,使得对应的缩略图行可见。文章通过HTML、CSS和JavaScript来实现这一功能,并提供了详细的代码示例。
摘要由CSDN通过智能技术生成
tga缩略图预览

tga缩略图预览

Thumbnail Grid with Expanding Preview

If you have searched images on Google recently, you might have noticed the interesting expanding preview for a larger image when you click on a thumbnail. It’s a really nice effect and it is very practical, making a search much easier. Today we want to show you how to create a similar effect on a thumbnail grid. The idea is to open a preview when clicking on a thumbnail and to show a larger image and some other content like a title, a description and a link.

如果您最近在Google上搜索过图片,则单击缩略图时可能会注意到有趣的扩展预览,可查看更大的图片。 这是一个非常不错的效果,而且非常实用,可以使搜索更加轻松。 今天我们要向您展示如何在缩略图网格上创建类似的效果。 这个想法是在单击缩略图时打开预览,并显示较大的图像和其他一些内容,例如标题,描述和链接。

The interesting part is to calculate the correct preview height and to scroll the page to the right position. We’ll expand the preview in a way so that we can see the respective thumbnail row and cover the rest of the remaining page. Note that we don’t use very large images for the preview in the demo so you might see a lot of empty space on large monitors.

有趣的部分是计算正确的预览高度并将页面滚动到正确的位置。 我们将以某种方式扩展预览,以便我们可以看到相应的缩略图行并覆盖其余页面的其余部分。 请注意,在演示中,我们不会使用非常大的图像进行预览,因此您可能会在大型显示器上看到很多空白。

The demo features some amazing artwork by Jaime Martinez.

该演示以Jaime Martinez的一些令人惊叹的艺术品为特色。

So let’s start!

因此,让我们开始吧!

标记 (The Markup)

Initially, we need a thumbnail grid for which we will use an unordered list. Each list item will contain an anchor which will have several data attributes:

最初,我们需要一个缩略图网格,为此我们将使用无序列表。 每个列表项将包含一个具有多个数据属性的锚点:


<ul id="og-grid" class="og-grid">
	<li>
		<a href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot.">
			<img src="images/thumbs/1.jpg" alt="img01"/>
		</a>
	</li>
	<li>
		<a href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/2.jpg" data-title="Veggies sunt bona vobis" data-description="Komatsuna prairie turnip wattle seed artichoke mustard horseradish taro rutabaga ricebean carrot black-eyed pea turnip greens beetroot yarrow watercress kombu.">
			<img src="images/thumbs/2.jpg" alt="img02"/>
		</a>
	</li>
	<li><!-- ... --></li>
	<!-- ... -->
</ul>

The href value will be used to construct the link in the preview description (this also comes in handy when JavaScript is disabled). The data-largesrc attribute contains the path to the larger image. data-title and data-description contain the title and description, respectively.

href值将用于在预览描述中构造链接(禁用JavaScript时,这也很方便)。 data-largesrc属性包含指向较大图像的路径。 data-titledata-description包含标题和描述。

When we click on a thumbnail, we want a preview element to appear under the list item. For that we will need to insert an element into the grid. In fact, we will use the list item itself and add the preview element after the anchor:

当我们单击缩略图时,我们希望预览元素出现在列表项下。 为此,我们将需要在网格中插入一个元素。 实际上,我们将使用列表项本身,并在锚点之后添加预览元素:


<li>

	<a href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/2.jpg" data-title="Veggies sunt bona vobis" data-description="Komatsuna prairie turnip wattle seed artichoke mustard horseradish taro rutabaga ricebean carrot black-eyed pea turnip greens beetroot yarrow watercress kombu.">
		<img src="images/thumbs/2.jpg" alt="img02"/>
	</a>
	
	<div class="og-expander">
		<div class=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值