重要提示:此文档不适用于您当前选择的格式电子邮件!
amp-instagram
描述
显示 Instagram 嵌入。
必需的脚本
<script async custom-element="amp-instagram" src="https://cdn.ampproject.org/v0/amp-instagram-1.0.js"></script>
<script async custom-element="amp-instagram" src="https://cdn.ampproject.org/v0/amp-instagram-1.0.js"></script> <link rel="stylesheet" href="https://cdn.ampproject.org/v0/amp-instagram-1.0.css">
行为
对于 Instagram 嵌入,width
和 height
属性是特殊的。 这些应该是 Instagram 图像的实际宽度和高度。 该系统会自动为 Instagram 在图像周围添加的“边框”添加空间。
许多 Instagram 都是正方形的。 当您设置 layout="responsive"
时,任何 width
和 height
值相同的值都适用。
示例
<amp-instagram data-shortcode="fBwFP" data-captioned width="400" height="400" layout="responsive" > </amp-instagram>
如果 Instagram 不是正方形,则需要输入图像的实际尺寸。
使用非响应式布局时,您需要考虑为图像周围的“instagram 边框”添加的额外空间。 目前,图像上方和下方有 48px,两侧有 8px。
在有效的 AMP 文档之外独立使用
Bento 允许您在非 AMP 页面中使用 AMP 组件,而无需完全提交到有效的 AMP。 您可以将这些组件放置在不支持 AMP 的框架和 CMS 中。 在我们的指南 在非 AMP 页面中使用 AMP 组件中阅读更多内容。
要查找 amp-instagram
的独立版本,请参阅 bento-instagram
。
属性
data-shortcode | Instagram data-shortcode 在每个 Instagram 照片 URL 中都可以找到。 例如,在 https://instagram.com/p/fBwFP 中, fBwFP 是 data-shortcode。 |
data-captioned | 包含 Instagram 说明。 amp-instagram 将尝试调整到正确的高度,包括说明。 |
通用属性 | 此元素包括扩展到 AMP 组件的通用属性。 |
需要更多帮助?
您已经阅读此文档很多次了,但它并没有真正涵盖您的所有问题? 也许其他人也有同样的感觉:在 Stack Overflow 上联系他们。
前往 Stack Overflow 发现错误或缺少功能?AMP 项目强烈鼓励您的参与和贡献! 我们希望您成为我们开源社区的持续参与者,但也欢迎您为自己特别热衷的问题做出一次性贡献。
前往 GitHub