我正在尝试在我正在开发的一个应用程序上创建一个按钮,当我单击该按钮时会启动GIF录制。我不熟悉GIF是如何制作的,也不知道我需要什么资源来创建它。我需要知道什么语言/工具才能做到这一点吗?
发布于 2021-06-11 04:50:22
这是在点击按钮或点击静止图像时播放gif的功能。
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];
}.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%;
}<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中
iframe {
position: absolute;
left: 20%;
width: 40%;
height 40%;
}<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>
https://stackoverflow.com/questions/67927629
复制相似问题