首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我该怎么做我自己的GIF启动器?

我该怎么做我自己的GIF启动器?
EN

Stack Overflow用户
提问于 2021-06-11 03:49:01
回答 1查看 17关注 0票数 0

我正在尝试在我正在开发的一个应用程序上创建一个按钮,当我单击该按钮时会启动GIF录制。我不熟悉GIF是如何制作的,也不知道我需要什么资源来创建它。我需要知道什么语言/工具才能做到这一点吗?

EN

回答 1

Stack Overflow用户

发布于 2021-06-11 04:50:22

这是在点击按钮或点击静止图像时播放gif的功能。

代码语言:javascript
复制
number = 0;
var animations = ['https://media.giphy.com/media/sCPGYa9EAeTFC/giphy.gif',
  'https://media.giphy.com/media/sCPGYa9EAeTFC/giphy.gif',
  'https://media.giphy.com/media/sCPGYa9EAeTFC/giphy.gif'
]; // array of gif

//function to play gif
function playGif() {
  image = document.getElementById('hiddenimageid');
  image.src = animations[number];
}
代码语言:javascript
复制
.gifButton {
  position: absolute;
  top: 10%;
  left: 25%;
}

.board {
  position: absolute;
  top: 20%;
  left: 10%;
  width: 50%;
  height: 50%;
  cursor: pointer;
}

.board img {
  width: 100%;
  height: 100%;
}
代码语言:javascript
复制
<body>
  <button class="gifButton" onclick="playGif()">Click to play Gif</button>
  <div class="board">
    <img src="https://im7.ezgif.com/tmp/ffffff-ezgif-7-0ed398c8bb8a-gif-jpg/frame_07_delay-0.13s.jpg" id="hiddenimageid" onclick="character();" />
  </div>
</body>

<!--The img src here is the still image to display before the gif starts running-->

或者,如果您只想显示链接中的Gif,则可以将其放入iframe中

代码语言:javascript
复制
iframe {
  position: absolute;
  left: 20%;
  width: 40%;
  height 40%;
}
代码语言:javascript
复制
<iframe src="https://giphy.com/embed/eoxomXXVL2S0E" width="480" height="360" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
<p><a href="https://giphy.com/gifs/internet-eoxomXXVL2S0E">via GIPHY</a></p>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67927629

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档