如何制作缩略图<img>单击时显示全尺寸图像?

2023-07-31前端开发问题
37

本文介绍了如何制作缩略图<img>单击时显示全尺寸图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

通常你有一个图像标签,其中 src 作为图像的来源,alt 作为替代文本:

Normally you have an image tage with the src as the source of the image and the alt as the alternative text:

<img src="image1.gif" alt="Image 1" />

你能有类似的东西吗?:

Can you have something like is?:

<img src="image1.gif" alt="image2.gif" />

这意味着 src 有一个图像源,而 alt 也有一个图像源.

So that means the src has an image source and the alt also has an image source.

我想要做的是使用 flickr api 从 flickr 中提取 2 个图像(一个拇指图像和一个正常大小的图像),当用户点击拇指时,会显示正常大小的图像.

What I want to do is pull 2 images from flickr using the flickr api (a thumb image and a normal sized image) and when the user clicks on the thumb, the normal sized image is shown.

我尝试过这样的事情:

<a href="image2.gif" ><img src="image1.gif"/></a>

...但我得到默认的not found' 图像作为拇指(即使图像确实存在).

...but I get the default 'not found' image as the thumb (even though the image does really exist).

我正在使用 JQuery/Javascript.

I am using JQuery/ Javascript.

欢迎和赞赏任何帮助、建议甚至替代方案.

Any help, suggestions or even alternatives are all welcome and appreciated.

谢谢

感谢山姆的回复,

我不喜欢灯箱,因为我觉得它太慢太花哨了.

I don't like lightbox because I find it too slow and fancy.

但我喜欢geowa4的想法.

但请保持你的答案......

but please, keep your answers coming...

谢谢

推荐答案

<a href="image2.gif" ><img src="image1.gif"/></a>

技术一直对我有用.我在超级碗日记中使用它效果很好,但我发现我使用的脚本被破坏了.修复它们后,我将在 URL 中进行编辑.

technique has always worked for me. I used it to good effect in my Super Bowl diary, but I see that the scripts I used are broken. Once I get them fixed I will edit in the URL.

这篇关于如何制作缩略图&lt;img&gt;单击时显示全尺寸图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

“数组中的每个孩子都应该有一个唯一的 key prop"仅在第一次呈现页面时
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)...
2024-04-20 前端开发问题
5

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13

getFullYear 在一年的第一天返回前一年
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)...
2024-04-20 前端开发问题
6