0

<amp-anim>gif 动画的标签。但我发现该<amp-img>标签可以显示 gif 动画。我知道<amp-anim>标签可以设置一个占位符,但我不需要它。我发现没有任何异议了。
所以,我的问题是“<amp-img>为 gif 动画使用标签有问题吗?”

如果要检查标签和标签的工作方式,请打开https://ampbyexample.com/playground/并粘贴下面的 html 代码。<amp-img><amp-anim>

<!doctype html>
<html ⚡&gt;
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <script async custom-element="amp-anim" src="https://cdn.ampproject.org/v0/amp-anim-0.1.js"></script>
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <link rel="canonical" href="https://ampbyexample.com/components/amp-anim/">
  <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>

  <h2>amp-anim supports gif animation</h2>
  <amp-anim width="245" height="300" src="/img/gopher.gif" alt="an animation"
            attribution="The Go gopher was designed by Reneee French and is licensed under CC 3.0 attributions.">
  </amp-anim>

  <h2>amp-img also supports gif animation</h2>
  <amp-img width="245" height="300" src="/img/gopher.gif" alt="an animation"
            attribution="The Go gopher was designed by Reneee French and is licensed under CC 3.0 attributions.">
  </amp-img>
</body>
</html>
4

2 回答 2

1

amp-anim和之间的唯一区别amp-img性能:amp-anim能够在动画离屏时降低 CPU 使用率

于 2017-03-25T01:48:34.477 回答
0

您可以在amp-anim 文档中阅读到 amp-anim 是 amp-anim 的扩展版本,amp-img因为它提供了特别考虑 GIF 动画的附加功能。只要为amp-img您工作,那么一定要使用它。

amp-anim 组件与 amp-img 元素非常相似,并提供额外的功能来管理动画图像(如 GIF)的加载和播放。

于 2017-03-12T01:30:10.343 回答