[英]How can I add a link to each image on this pure HTML/CSS slideshow?
I'm trying make images in a slideshow behave like links, so when user clicks on the image it will take them to that url.我正在尝试使幻灯片中的图像表现得像链接,因此当用户单击图像时,它会将它们带到该 url。
The slideshow is made using css animations.幻灯片是使用 css 动画制作的。 It's based on this tutorial .
它基于本教程。
As you can see I already tried wrapping it in an tag but that doesn't work, I think the animation is affecting the images ability to work as a link...正如你所看到的,我已经尝试将它包装在一个标签中,但这不起作用,我认为动画正在影响图像作为链接工作的能力......
My HTML我的 HTML
<div class="slideshow">
<figure>
<img src="c5.jpg" width="484" height="330" />
</figure>
<figure>
<img src="14.jpg" width="484" height="330" />
</figure>
<figure>
<a href="c3.html"><img src="c3.jpg" width="484" height="330"/></a>
</figure>
<figure>
<img src="c2.jpg" width="484" height="330" />
</figure>
<figure>
<a href="c12.html"><img src="12.png" width="484" height="330" /></a>
</figure>
</div>
Some of my CSS:我的一些 CSS:
.slideshow figure:nth-child(1) {
-webkit-animation: goldfade 20s 16s infinite;
-moz-animation: goldfade 20s 16s infinite;
-ms-animation: goldfade 20s 16s infinite;
animation: goldfade 20s 16s infinite;
}
.slideshow figure:nth-child(2) {
-webkit-animation: goldfade 20s 12s infinite;
-moz-animation: goldfade 20s 12s infinite;
-ms-animation: goldfade 20s 12s infinite;
animation: goldfade 20s 12s infinite;
}
@-webkit-keyframes "goldfade" {
0% {
filter: alpha(opacity=100);
opacity: 1;
}
18% {
filter: alpha(opacity=100);
opacity: 1;
}
20% {
filter: alpha(opacity=0);
opacity: 0;
}
96% {
filter: alpha(opacity=0);
opacity: 0;
}
100% {
filter: alpha(opacity=100);
opacity: 1;
}
}
wrap the image tags with an anchor tag and provide the href attribute your desired link.Then your image will act like a link.That might serve your purpose用锚标记包装图像标签并提供所需链接的 href 属性。然后您的图像将像一个链接一样。这可能符合您的目的
<a href='....your link...'>
<img src='imageName.png'>
</a>
change the href to the img's src property, if you're trying to open the image:如果您尝试打开图像,请将 href 更改为 img 的 src 属性:
<a href="c13.jpg">
<img src="c13.jpg">
</a>
I am seeking to do the same thing, but neither answer above seems to work.我正在寻求做同样的事情,但上面的答案似乎都不起作用。 The example given above already has each
<img>
surrounded with an anchor.上面给出的示例已经将每个
<img>
用一个锚点包围起来。 When I try wrapping each image with a unique anchor, only the last anchor defined works.当我尝试用唯一的锚点包装每个图像时,只有最后一个定义的锚点有效。
Add anchor tag in all slider_images for providing link:在所有滑块图像中添加锚标记以提供链接:
<a href='link of page that you want to open'>
<img src='image.jpg'>
</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.