简体   繁体   English

如何在此纯 HTML/CSS 幻灯片上添加指向每个图像的链接?

[英]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.

相关问题 CSS幻灯片-如何向图像添加链接? - CSS slideshow - How can I add a link to the image? 如何自动播放此纯CSS3幻灯片? - How can I autoplay this pure CSS3 slideshow? 如何将CSS幻灯片中的每个图像链接到网站上的其他页面? - How do I link each image in my CSS slideshow to a different page on my site? 我想在我的网站上添加幻灯片。 我正在使用html,css,并希望使用jquery。 如何创建响应式图像幻灯片 - I want to add a slideshow to my website. I'm using html, css, and want to use jquery. How can I create a responsive image slideshow 如何使用 html 和 css 编写幻灯片? - How can I program a slideshow with html and css? 为什么我不能在纯 css 幻灯片中添加新幻灯片? - Why can't i add a new slide to my pure css slideshow? 如何在纯CSS滑块中为每个图像添加唯一的链接? - How do I add unique links to each image in my pure css slider? 如何使用HTML,CSS和Javascript制作幻灯片显示,以在iPhone的图像上显示应用程序的图像? - How can I make a slideshow using HTML, CSS, and Javascript displaying an app's images on an image of an iPhone? 如何在HTML5 / CSS3幻灯片中添加更多图像 - How can I add more images to my HTML5/CSS3 Slideshow 如何在 html 和 css 上的图像链接轮廓上添加颜色? - How can I put color on a Image link outline on html and css?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM