如何制作可点击的 gif 并使其 link 到某个地方?

How to make clickable gif and make it link to somewhere?

所以我对我想做的事情有一个雄心勃勃的想法,想知道实现它的最佳方式,或者是否可能。

我想要它,所以当我将鼠标悬停在其中一个选项卡上时,它会播放一次 gif 动画(例如一些箭头或其他东西),然后将其留在最后一帧中(因此它不会连续循环然后可以点击。

我怀疑我的代码是否有任何帮助,但无论如何我都会把它留在这里(我知道它很乱,我应该修复它,但我对此有点陌生。)

<!DOCTYPE html>
<html lang="en-US">
<html>
<style>

head {
background-color: white;
}

span.mainbar {
display: inline-block;
margin-left:10px;
margin-top:3px; 
}

span.text {
display: inline-block;
float:right;
margin-right:25px;
margin-top: 27px;   
}

span.bar
{
display: inline-block;
float:right;
margin-right:25px;
margin-top: 20px;   
}  

span.facebook {
display: inline-block;
float:right;
margin-right:30px;
margin-top: 22px;   
}

span.instagram{
display: inline-block;
float:right;
margin-right:22px;
margin-top: 22px;   
}

span.twitter{
display: inline-block;
float:right;
margin-right:30px;
margin-top: 16px;   
}


</style>
<head>
<title> The Project </title>
<link rel="shortcut icon" href="images/favicon.ico"/>

<span class="mainbar">
<a href="Homepage.html">
<img src="images/Temp Text Logo.png" alt="Main Logo" style=";border:0;">
</a>
</span>

<Span class="twitter">
<a href="https://www.twitter.com"target="_blank">
<img src="images/twitter.png" alt="twitter page" 
style="width:50px;height50px:;border:0;">
</a>
</span>

<Span class="instagram">
<a href="https://www.instagram.com"target="_blank">
<img src="images/instagram.png" alt="instagram page" style=";border:0;">
</a>
</span>

<Span class="facebook">
<a href="https://www.facebook.com"target="_blank">
<img src="images/facebook.png" alt="facebook page" style=";border:0;">
</a>
</span>

<span class="bar">
<img src="images/bar.png" alt="bar" style=";border:0;">
</a>
</span>

<span class="text">
<a href="about.html">
<img src="images/about.png" alt="about" style=";border:0;">
</a>
</span>

<span class="text">
<a href="shop.html">
<img src="images/shop.png" alt="shop" style=";border:0;">
</a>
</span>

<span class="text">
<a href="Homepage.html">
<img src="images/home.png" alt="Home" style=";border:0;">
</a>
</span>

</head>



<body>
<hr>
</hr>
</body>

</html>

Tab example pic

要使图像可点击,您需要做的就是将图像包装在 hyperlink 父级中:

<a href="http://www.google.com">
  <img src="http://placehold.it/100">
</a>

至于只允许link在动画播放后可以点击,理论上可能到JavaScript,但我不会'不建议这样做。唯一的方法是使用 timeOut,您可能会遇到时间不同步的情况。

除此之外,我建议使用 sprite 贴图而不是 GIF。

希望对您有所帮助! :)

没有javascript/jquery控制就无法控制gif动画。

  • 有2张图片,一张静态图片和一张动画图片,用jquery控制动画的开始,像这样解决:Stop a gif animation onload, on mouseover start the activation

  • 像这样使用 jquery 插件:http://rubentd.com/gifplayer/