當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。