Google AMP amp-lightbox-gallery

Опубликовано: 12 Апреля, 2022

Компонент amp-lightbox-gallery используется для создания эффекта лайтбокса для других компонентов усилителя, таких как amp-carousel, amp-img. В настоящее время amp-lightbox-gallery поддерживает только изображения.

Required Script: Importing the amp-lightbox-gallery component into the header.

HTML

<script async custom-element="amp-lightbox-gallery" src=
</script>

Атрибуты:

  • лайтбокс: мы используем этот атрибут, чтобы добавить к изображениям эффект лайтбокса.
  • src: укажите URL-адрес или путь к изображению, которое необходимо встроить.
  • layout: определяет макет изображения, например, отзывчивый.

Example:

HTML

<!doctype html>
<html >
  
<head>
    <meta charset="utf-8">
    <link rel="canonical" href=
  
    <meta name="viewport" content=
        "width=device-width,minimum-scale=1,
        initial-scale=1">
  
    <script async src=
    </script>
  
    <script async custom-element="amp-carousel"
    </script>
  
    <title>Google AMP amp-lightbox-gallery</title>
  
    <!-- Import the amp-lightbox-gallery 
        component in the header.  -->
    <script async custom-element="amp-lightbox-gallery"
    </script>
  
    <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>
    <style amp-custom>
        :root {
            --color-primary: #005AF0;
            --color-text-light: #fff;
            --space-1: .5rem;
            --space-2: 1rem;
        }
    </style>
</head>
  
<body>
    <div>
        <amp-img lightbox src=
            width="300" height="200"
            layout="responsive">
        </amp-img>
  
        <p class="paragraph">
            welcome to geeksforgeeks
        </p>
  
          
        <amp-img lightbox
            src=
            width="300" height="200"
            layout="responsive">
        </amp-img>
  
        <p class="paragraph">
            GeeksforGeeks A Computer Science 
            portal for geeks.
        </p>
  
    </div>
</body>
  
</html>

Выход:

Вывод кода

При нажатии на изображение открывается следующий вид

На изображении щелкните

При нажатии на опцию галереи в верхнем левом углу открывается следующий вид

Просмотр галереи

РЕКОМЕНДУЕМЫЕ СТАТЬИ