显示多图像(动画)GIF 文件中的单个图像
简单的问题,真的。我只是不具备使用 JavaScript 执行此操作的知识,以及确保它适用于(几乎)所有浏览器......
我将设计一组一个人用一只手指向多个方向的图像。 (上、下、左、右、对角线等)基本上,这个木偶将指向鼠标的位置。为此,我想使用一个动画 GIF 文件来包含所有图像,然后使用 JavaScript 根据鼠标相对于图像的位置将正确的图像置于前面。
不过,我对 Javascript 的了解非常有限。在开始创建 GIF 图像之前,我想知道这是否可行,以及是否有适用于任何网络浏览器的解决方案。 (当然,除非它不支持 JavaScript。)
我知道可以从 JavaScript 延迟动画 GIF,但是否也可以修改需要显示的确切图像?
Simple question, really. I just don't have the knowledge to do this with JavaScript, and to also make sure it works with (almost) all browsers...
I am going to design a set of images of a person pointing with one hand in several directions. (Up, down, left, right, diagonal, etc.) Basically, this puppet will be pointing at the location of the mouse. To do so, I want to use an animated GIF file to contain all the images and then use JavaScript to bring the right image to the front, based on the position of the mouse in relation with the image.
My knowlegde of Javascript is very limited, though. Before I even start creating the GIF images, I want to know if it's possible and if there's a solution that would work on any web browser. (Unless it doesn't support JavaScript, of course.)
I know it's possible to delay an animated GIF from JavaScript but is it also possible to modify the exact image that needs to be displayed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,这是不可能的。
像这样的事情通常是使用 "CSS sprites" 技术完成的,其中各个阶段彼此相邻地粘合成一张巨大的图像。然后该图像将在较小的元素中用作背景图像。
background-position
将确定显示哪个图像。这是否适合您取决于您的图像尺寸是否相同。它的优点是可以在所有浏览器中可靠地工作,甚至是 IE6。
As far as I know, this is not possible.
Stuff like this is usually done using the "CSS sprites" technique, where the various stages are glued next to each other into one giant image. That image will then be used as
background-image
in a smaller element.background-position
will determine which image is shown.Whether this works for you will depend on whether your images are all the same size or not. It has the advantage of working reliably in all browsers, even IE6.