当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Google AMP amp-instagram用法及代码示例


添加社交媒体帖子时,评论是网站开发人员倾向于添加的有吸引力的函数,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>

输出:




相关用法


注:本文由纯净天空筛选整理自somsagar2019大神的英文原创作品 Google AMP amp-instagram。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。