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

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

问题描述

我在静态 HTML 文档中有以下 标签.

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 behavior. If the 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天全站免登陆