Google AMP amp-lightbox-gallery

 

The amp-lightbox-gallery component is used to give a lightbox experience for other amp components like amp-carousel, amp-img. Presently only images are supported by amp-lightbox-gallery.

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

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Attributes:



  • lightbox: We use this attribute to add a lightbox effect to the images.
  • src: Specify the URL or the path of the image that is to be embedded.
  • layout: Specifies the layout of the image e.g. responsive.

Example:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

Code output

Clicking on the image gives the following view

On image click

Clicking on the top left gallery option gives the following view

Gallery view




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.