AMP

amp-anim

Description

Manages an animated image, typically a GIF.

 

Required Scripts

<script async custom-element="amp-anim" src="https://cdn.ampproject.org/v0/amp-anim-0.1.js"></script>

Usage

The amp-anim component displays a GIF animation with optimized CPU management.

The amp-anim component lets the AMP framework reduce the resources it spends on the animation when it's off-screen. Otherwise, the behavior of amp-anim is identical to amp-img. You can implement a placeholder element to further optimize amp-anim.

<amp-anim width="400" height="300" src="my-gif.gif">
  <amp-img placeholder width="400" height="300" src="my-gif-screencap.jpg">
  </amp-img>
</amp-anim>

Attributes

src

Specifies the URL for a GIF image.

alt

Provides a string of alternate text for accessibility purposes. Operates the same as the alt attribute on the img tag.

attribution

Indicates the attribution of the image. For example, attribution="CC courtesy of Cats on Flicker".

width and height

Provides the explicit size of the image.

Common attributes

amp-anim includes the common attributes extended to AMP components.

Styling

You can directly style amp-anim with CSS properties. The following example sets a grey background placeholder:

<style amp-custom>
  .amp-anim {
      background-color: grey;
  }
</style>

Validation

See amp-anim rules in the AMP validator specification.

Bạn cần được trợ giúp thêm?

Bạn đã đọc tài liệu này hàng chục lần, nhưng nó không thật sự trả lời mọi thắc mắc của bạn? Có lẽ những người khác cũng cảm thấy như vậy: hãy liên hệ với họ trên Stack Overflow.

Truy cập Stack Overflow
Bạn tìm thấy một lỗi hoặc cần bổ sung một tính năng?

Dự án AMP đặc biệt khuyến khích sự tham gia và đóng góp của bạn! Chúng tôi hi vọng bạn sẽ trở thành một người tham gia tích cực trong cộng đồng mã nguồn mở của chúng tôi, nhưng chúng tôi cũng chào mừng các đóng góp đơn lẻ về vấn đề mà bạn đặc biệt quan tâm.

Truy cập GitHub