¿Cómo agregar un Slideshow con reproducción automática y Lightbox con AMP?
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'/>
<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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3xWdF9AsnrnANstgTOgDYNZCep9VTMDJOmbQP3z59RzVS7AME_sgoW8zIWYGp4PCHJmERmXdvTSvTx1UZxx7qnj1M_guNWxgbPc-TFElSWyyqTeKgBls0kgJugJZMNcYqPj9e_9PxwxU/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxRLOoZ4ZEPSEMRKoQ83QH04MOLDgP_woJhA-o4-DtlX_mmLy7vZCgZYDms8cF9Xe8JViJCDMNFx9H5VoOvMU7ZL70uuIZIJ9a5hwP3_FDd3ysXZp-UpxAhmN9oam2_-zXv8DnWBgqiDc/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQv2rqrF73Uic6PJAPu6xNPblMHfAwyl7EkiTKjhKoJ5x9QOlBHKBq-wnr7lhyphenhyphen1zqJMr2c1_40yMcS5Fp2fKrvdr6wCmzrGpgVN91XQ08oyturYWh2dbQReP3V1JyPlPSosE51NS9tDhw/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVg5aDyQoJ6DbobqOPMjQrDuO30KW-WnBtsK6kQrxhaToSJZB6bPhOl962TkpTw0v7Vp4XqIzUAbu-v8pUg59lgSEiiwcFr6gDJSS641KUngK4bAf_tKbQk7Bx7ZO2iU_TCSaZ6nwtQEo/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyZpCUhBSPwK0zvWypINKibB2GPzO7IBiajidoPzBLuV_aJN0-rtYyIHJUrMhyiohi53mtWqc4m7Nm9WUMDHTFaY2HJu092ECuzVD6hTZv7Ck8q8lVXJR-vDiC0DnzMWiDQFjDwFPw7ZQ/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV0yJzsjq4xQZsMo0AMZKUO7d7nuDuW829OFS-JK4cvsUCY_IN6mV1cI2w-LXUixJgYv-dueiyvRRCt5rov07G5uuQrdThTAFm3fDSrs8BLSLePyS4dtaoSxsJI2yTfiJ27IfMr0EZIec/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>
<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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3xWdF9AsnrnANstgTOgDYNZCep9VTMDJOmbQP3z59RzVS7AME_sgoW8zIWYGp4PCHJmERmXdvTSvTx1UZxx7qnj1M_guNWxgbPc-TFElSWyyqTeKgBls0kgJugJZMNcYqPj9e_9PxwxU/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxRLOoZ4ZEPSEMRKoQ83QH04MOLDgP_woJhA-o4-DtlX_mmLy7vZCgZYDms8cF9Xe8JViJCDMNFx9H5VoOvMU7ZL70uuIZIJ9a5hwP3_FDd3ysXZp-UpxAhmN9oam2_-zXv8DnWBgqiDc/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQv2rqrF73Uic6PJAPu6xNPblMHfAwyl7EkiTKjhKoJ5x9QOlBHKBq-wnr7lhyphenhyphen1zqJMr2c1_40yMcS5Fp2fKrvdr6wCmzrGpgVN91XQ08oyturYWh2dbQReP3V1JyPlPSosE51NS9tDhw/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVg5aDyQoJ6DbobqOPMjQrDuO30KW-WnBtsK6kQrxhaToSJZB6bPhOl962TkpTw0v7Vp4XqIzUAbu-v8pUg59lgSEiiwcFr6gDJSS641KUngK4bAf_tKbQk7Bx7ZO2iU_TCSaZ6nwtQEo/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyZpCUhBSPwK0zvWypINKibB2GPzO7IBiajidoPzBLuV_aJN0-rtYyIHJUrMhyiohi53mtWqc4m7Nm9WUMDHTFaY2HJu092ECuzVD6hTZv7Ck8q8lVXJR-vDiC0DnzMWiDQFjDwFPw7ZQ/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV0yJzsjq4xQZsMo0AMZKUO7d7nuDuW829OFS-JK4cvsUCY_IN6mV1cI2w-LXUixJgYv-dueiyvRRCt5rov07G5uuQrdThTAFm3fDSrs8BLSLePyS4dtaoSxsJI2yTfiJ27IfMr0EZIec/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3xWdF9AsnrnANstgTOgDYNZCep9VTMDJOmbQP3z59RzVS7AME_sgoW8zIWYGp4PCHJmERmXdvTSvTx1UZxx7qnj1M_guNWxgbPc-TFElSWyyqTeKgBls0kgJugJZMNcYqPj9e_9PxwxU/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxRLOoZ4ZEPSEMRKoQ83QH04MOLDgP_woJhA-o4-DtlX_mmLy7vZCgZYDms8cF9Xe8JViJCDMNFx9H5VoOvMU7ZL70uuIZIJ9a5hwP3_FDd3ysXZp-UpxAhmN9oam2_-zXv8DnWBgqiDc/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQv2rqrF73Uic6PJAPu6xNPblMHfAwyl7EkiTKjhKoJ5x9QOlBHKBq-wnr7lhyphenhyphen1zqJMr2c1_40yMcS5Fp2fKrvdr6wCmzrGpgVN91XQ08oyturYWh2dbQReP3V1JyPlPSosE51NS9tDhw/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVg5aDyQoJ6DbobqOPMjQrDuO30KW-WnBtsK6kQrxhaToSJZB6bPhOl962TkpTw0v7Vp4XqIzUAbu-v8pUg59lgSEiiwcFr6gDJSS641KUngK4bAf_tKbQk7Bx7ZO2iU_TCSaZ6nwtQEo/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyZpCUhBSPwK0zvWypINKibB2GPzO7IBiajidoPzBLuV_aJN0-rtYyIHJUrMhyiohi53mtWqc4m7Nm9WUMDHTFaY2HJu092ECuzVD6hTZv7Ck8q8lVXJR-vDiC0DnzMWiDQFjDwFPw7ZQ/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV0yJzsjq4xQZsMo0AMZKUO7d7nuDuW829OFS-JK4cvsUCY_IN6mV1cI2w-LXUixJgYv-dueiyvRRCt5rov07G5uuQrdThTAFm3fDSrs8BLSLePyS4dtaoSxsJI2yTfiJ27IfMr0EZIec/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>
<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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3xWdF9AsnrnANstgTOgDYNZCep9VTMDJOmbQP3z59RzVS7AME_sgoW8zIWYGp4PCHJmERmXdvTSvTx1UZxx7qnj1M_guNWxgbPc-TFElSWyyqTeKgBls0kgJugJZMNcYqPj9e_9PxwxU/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxRLOoZ4ZEPSEMRKoQ83QH04MOLDgP_woJhA-o4-DtlX_mmLy7vZCgZYDms8cF9Xe8JViJCDMNFx9H5VoOvMU7ZL70uuIZIJ9a5hwP3_FDd3ysXZp-UpxAhmN9oam2_-zXv8DnWBgqiDc/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQv2rqrF73Uic6PJAPu6xNPblMHfAwyl7EkiTKjhKoJ5x9QOlBHKBq-wnr7lhyphenhyphen1zqJMr2c1_40yMcS5Fp2fKrvdr6wCmzrGpgVN91XQ08oyturYWh2dbQReP3V1JyPlPSosE51NS9tDhw/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVg5aDyQoJ6DbobqOPMjQrDuO30KW-WnBtsK6kQrxhaToSJZB6bPhOl962TkpTw0v7Vp4XqIzUAbu-v8pUg59lgSEiiwcFr6gDJSS641KUngK4bAf_tKbQk7Bx7ZO2iU_TCSaZ6nwtQEo/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyZpCUhBSPwK0zvWypINKibB2GPzO7IBiajidoPzBLuV_aJN0-rtYyIHJUrMhyiohi53mtWqc4m7Nm9WUMDHTFaY2HJu092ECuzVD6hTZv7Ck8q8lVXJR-vDiC0DnzMWiDQFjDwFPw7ZQ/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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV0yJzsjq4xQZsMo0AMZKUO7d7nuDuW829OFS-JK4cvsUCY_IN6mV1cI2w-LXUixJgYv-dueiyvRRCt5rov07G5uuQrdThTAFm3fDSrs8BLSLePyS4dtaoSxsJI2yTfiJ27IfMr0EZIec/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>
</body>
</html>
Comentarios
Disqus comments:
Facebook comments: