如何在HTML文档中制作GIF动画? [英] How to animate GIFs in HTML document?

查看:398
本文介绍了如何在HTML文档中制作GIF动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在静态HTML文档中具有以下<img>标记.

I have the following <img> tag in a static HTML document.

<img src="foo.gif" alt="This is an animated gif image, but it does not move"/>

在将其src属性设置为指向.gif文件(即foo.gif)后,GIF会显示为静态(或非移动)图像.如何为GIF制作动画?

After I set its src attribute to point to a .gif file (i.e. foo.gif), the GIF appears as a static (or non-moving) image. How do I animate the GIF?

推荐答案

默认情况下,浏览器始终会播放动画gif,并且您无法更改其行为.如果gif图像没有动画,则有两种查看方式:浏览器有问题,图像有问题.然后要排除第一个变体,只需在浏览器中检查受信任的图像(运行下面的代码段,此gif肯定是动画的,并且可以在所有浏览器中使用).

By default browser always plays animated gifs, and you can't change that behaviour. If gif image does not animate there can be 2 ways to look: something wrong with the browser, something wrong with the image. Then to exclude the first variant just check trusted image in your browser (run snippet below, this gif definitely animated and works in all browsers).

您的代码看起来不错. 您可以检查此代码段是否为您动画化了吗?
如果,则说明您的gif出现问题,如果,则说明您的浏览器有问题.

Your code looks OK. Can you check if this snippet is animated for you?
If YES, then something is bad with your gif, if NO something is wrong with your browser.

<img src="http://i.stack.imgur.com/SBv4T.gif" alt="this slowpoke moves"  width=250/>

这篇关于如何在HTML文档中制作GIF动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆