¿Cómo agregar un Slideshow con reproducción automática y Lightbox con AMP?

Aprenda a insertar un Slideshow con reproducción automática y Lightbox con AMP. Slider With Autoplay And Lightbox.

AMP lightbox es perfecto para la web moderna, con funciones totalmente dinámicas

Vamos a utilizar los siguientes componentes:

amp-image-lightbox
amp-carousel

AMP Slider With Autoplay And Lightbox

Paso 1 Agregar los componentes

Ejemplo

<script async src='https://cdn.ampproject.org/v0.js'/>
<script async custom-element='amp-image-lightbox' src='https://cdn.ampproject.org/v0/amp-image-lightbox-0.1.js'/>
<script async custom-element='amp-carousel' src='https://cdn.ampproject.org/v0/amp-carousel-0.1.js'/>

Paso 2 Agregar el siguiente código después de la apertura <body>

Ejemplo

<section>
<div class="container">   
<div class="slider-box" data-autoplay="true" data-delay="3000">
<amp-carousel class="carousel" height="9" width="16" layout="responsive" type="slides" loop="" autoplay="autoplay" delay="3000">

<amp-img class="carousel-img" src="https://2.bp.blogspot.com/-ngV6Rc1lGsU/Wue14GzaH3I/AAAAAAAAZXU/FWQTxPVnigo_JaewHQwPOIs7dGpEJitxwCLcBGAs/s1600/blog-3.jpg" on="tap:lightbox1" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">
                    </div>
                  </amp-img>

<amp-img class="carousel-img" src="https://2.bp.blogspot.com/-IeLNdqTgjAM/Wue16ds5MXI/AAAAAAAAZXY/XN6JGUxmACYrGxfSfAG0d0-R-x_t8PYLQCLcBGAs/s1600/business-1.jpg" on="tap:lightbox2" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-vBzYo5JZgwQ/Wue187US7JI/AAAAAAAAZXc/33_Isf-xAJATDV46jPKoWPG_noZlA-AOwCLcBGAs/s1600/funfact.jpg" on="tap:lightbox3" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                </amp-img>

<amp-img class="carousel-img" src="https://1.bp.blogspot.com/--j15dxhVK8Q/Wue1_LsgcsI/AAAAAAAAZXg/TaxIu6fs4dAFi29mj3IQt8Rm7XFSic0UQCLcBGAs/s1600/home-bg.jpg" on="tap:lightbox4" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>                 
                </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-ZqcITJeOp6g/Wue2nZY3M0I/AAAAAAAAZXw/TAXq2O9YJ5IeDnmuiUwS3usBp5zs2rd_gCLcBGAs/s1600/img-1.jpg" on="tap:lightbox5" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                 </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-zIIOPmd84c0/Wue2pduVHbI/AAAAAAAAZX0/8g7hPbV-UAMFReXAiq7PyMWemKpTZBmwQCLcBGAs/s1600/img-2.jpg" on="tap:lightbox6" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                 
                </amp-img>
            </amp-carousel>
        </div>
    </div>
    <amp-image-lightbox id="lightbox1" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox2" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox3" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox4" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox5" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox6" layout="nodisplay"></amp-image-lightbox>
</section>

Paso 3 Cambie las URLs de imagenes

Paso 4 Demostración

A continuación la estructura completa del ejemplo

Ejemplo

<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element='amp-image-lightbox' src='https://cdn.ampproject.org/v0/amp-image-lightbox-0.1.js'/>
<script async custom-element='amp-carousel' src='https://cdn.ampproject.org/v0/amp-carousel-0.1.js'/>
<link rel="canonical" href="https://www.amphtmlenespanol.com/">

<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">

<style amp-custom>

</style>

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

<section>
<div class="container"> 
<div class="slider-box" data-autoplay="true" data-delay="3000">
<amp-carousel class="carousel" height="9" width="16" layout="responsive" type="slides" loop="" autoplay="autoplay" delay="3000">

<amp-img class="carousel-img" src="https://2.bp.blogspot.com/-ngV6Rc1lGsU/Wue14GzaH3I/AAAAAAAAZXU/FWQTxPVnigo_JaewHQwPOIs7dGpEJitxwCLcBGAs/s1600/blog-3.jpg" on="tap:lightbox1" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">
                    </div>
                  </amp-img>

<amp-img class="carousel-img" src="https://2.bp.blogspot.com/-IeLNdqTgjAM/Wue16ds5MXI/AAAAAAAAZXY/XN6JGUxmACYrGxfSfAG0d0-R-x_t8PYLQCLcBGAs/s1600/business-1.jpg" on="tap:lightbox2" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-vBzYo5JZgwQ/Wue187US7JI/AAAAAAAAZXc/33_Isf-xAJATDV46jPKoWPG_noZlA-AOwCLcBGAs/s1600/funfact.jpg" on="tap:lightbox3" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                </amp-img>

<amp-img class="carousel-img" src="https://1.bp.blogspot.com/--j15dxhVK8Q/Wue1_LsgcsI/AAAAAAAAZXg/TaxIu6fs4dAFi29mj3IQt8Rm7XFSic0UQCLcBGAs/s1600/home-bg.jpg" on="tap:lightbox4" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>               
                </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-ZqcITJeOp6g/Wue2nZY3M0I/AAAAAAAAZXw/TAXq2O9YJ5IeDnmuiUwS3usBp5zs2rd_gCLcBGAs/s1600/img-1.jpg" on="tap:lightbox5" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
                 </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-zIIOPmd84c0/Wue2pduVHbI/AAAAAAAAZX0/8g7hPbV-UAMFReXAiq7PyMWemKpTZBmwQCLcBGAs/s1600/img-2.jpg" on="tap:lightbox6" role="button" tabindex="0" height="9" width="12" layout="responsive" alt="">
                    <div placeholder="">

                    </div>
               
                </amp-img>
            </amp-carousel>
        </div>
    </div>
    <amp-image-lightbox id="lightbox1" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox2" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox3" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox4" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox5" layout="nodisplay"></amp-image-lightbox>
    <amp-image-lightbox id="lightbox6" layout="nodisplay"></amp-image-lightbox>

</section>
</body>
</html>



Share:

Related post

Disqus

Disqus comments:


Facebook

Facebook comments: