¿Cómo agregar un Carrusel de ancho completo con imágenes en AMP?

Aprenda a insertar un Carrusel de ancho completo con imágenes en lightbox con AMP. Full width carousel with images in lightbox.

Vamos a utilizar los siguientes componentes:

amp-image-lightbox
amp-carousel

AMP Full width carousel with images in 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-fluid">
<div class="slider-box">
            <amp-carousel class="carousel" height="300" layout="fixed-height" type="carousel">

<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="300" width="450" alt="">
                    <div placeholder="">
                     
                    </div>
                 </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-NMfnLluHHfc/Wxh0oSLZx-I/AAAAAAAAZ9A/sQtVZ6OYlWImfTHQgf6QdEBFMsdIpgsKgCLcBGAs/s1600/amp-i.jpg" on="tap:lightbox2" role="button" tabindex="0" height="300" width="450" 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="300" width="450" 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="300" width="450" 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="300" width="450" 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="300" width="450" 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-fluid">
<div class="slider-box">
            <amp-carousel class="carousel" height="300" layout="fixed-height" type="carousel">

<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="300" width="450" alt="">
                    <div placeholder="">
                     
                    </div>
                 </amp-img>

<amp-img class="carousel-img" src="https://4.bp.blogspot.com/-NMfnLluHHfc/Wxh0oSLZx-I/AAAAAAAAZ9A/sQtVZ6OYlWImfTHQgf6QdEBFMsdIpgsKgCLcBGAs/s1600/amp-i.jpg" on="tap:lightbox2" role="button" tabindex="0" height="300" width="450" 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="300" width="450" 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="300" width="450" 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="300" width="450" 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="300" width="450" 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

Comentarios

Disqus

Disqus comments:


Facebook

Facebook comments: