添加社交媒体帖子时,评论是网站开发人员倾向于添加的有吸引力的函数,Instagram成为2020年流行的社交媒体网络之一,在嵌入Instagram帖子时可以吸引观众。在AMP HTML中,我们可以使用amp-instagram来完成此操作。
必需的脚本:将amp-instagram标头导入标头。
HTML
<script async custom-element="amp-instagram"
src="https://cdn.ampproject.org/v0/amp-instagram-0.1.js">
</script>
属性:
- data-shortcode:在每个Instagram照片URL中找到。在下面的链接https://www.instagram.com/p/CEZCQC-osEP/中使用加粗下划线的示例
- data-captioned:将调整为包括字幕在内的原始高度。
例:
HTML
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>Google AMP amp-instagram</title>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<link rel="canonical" href=
"https://amp.dev/documentation/examples/components/amp-instagram/index.html">
<!-- Import the amp-instagram component
in the header -->
<script async custom-element="amp-instagram"
src="https://cdn.ampproject.org/v0/amp-instagram-0.1.js">
</script>
<meta name="viewport" content=
"width=device-width,minimum-scale=1,initial-scale=1">
<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>
<amp-instagram data-shortcode="CEZCQC-osEP"
width="1" height="1" layout="responsive">
</amp-instagram>
<!-- You can include captions with the
`data-captioned` attribute -->
<amp-instagram data-shortcode="CEQ17teInqd"
data-captioned width="1" height="1"
layout="responsive">
</amp-instagram>
</body>
</html>
输出:
相关用法
- Google AMP amp-ad用法及代码示例
- Google AMP amp-accordion用法及代码示例
- Google AMP amp-facebook-like用法及代码示例
- Google AMP amp-carousel用法及代码示例
- Google AMP amp-date-countdown用法及代码示例
- Google AMP amp-brightcove用法及代码示例
- Google AMP amp-bind-recaptcha用法及代码示例
- Google AMP amp-autocomplete用法及代码示例
- Google AMP amp-img用法及代码示例
- Google AMP amp-image-lightbox用法及代码示例
- Google AMP amp-lightbox-gallery用法及代码示例
- Google AMP amp-soundcloud用法及代码示例
- Google AMP amp-mustache用法及代码示例
注:本文由纯净天空筛选整理自somsagar2019大神的英文原创作品 Google AMP amp-instagram。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。