Presentación de diapositivas con fundido cruzado HTML5/CSS3 puro

Tiempo de ejecución: 30 minutos. Empezar

Autor: alexerlandsson
Views Total: 3,990
Sitio oficial: Ir a la web
Actualizado: May 14, 2016
Licencia: MIT

Vista prévia

Presentación de diapositivas con fundido cruzado HTML5/CSS3 puro

Descripción

Una presentación de diapositivas de fondo de pantalla completa con un efecto de fundido cruzado, construido con HTML5 y CSS3. No se requiere ningún JavaScript.

Funcionamiento

Agregue contenido personalizado junto con imágenes de fondo y controles de navegación a la proyección de diapositivas.

<div class="container">



<div data-am-gallery="3 next-prev-navigation">



<!-- Radio -->


<input type="radio" name="gallery" id="img-1" checked />


<input type="radio" name="gallery" id="img-2" />


<input type="radio" name="gallery" id="img-3" />



<!-- Images -->


<div class="images">



<div class="image" style="background-image: url(1.jpg);">




<!-- Add content to images -->




</div>



</div>



<div class="image" style="background-image: url(2.jpg);"></div>



<div class="image" style="background-image: url(3.jpg"></div>


</div>



<!-- Navigation -->


<div class="navigation">



<label class="dot" for="img-1"></label>



<label class="dot" for="img-2"></label>



<label class="dot" for="img-3"></label>


</div>





<!-- Prev next navigation -->


<div class="prev-container">



<label class="prev" for="img-1"></label>



<label class="prev" for="img-2"></label>



<label class="prev" for="img-3"></label>


</div>


<div class="next-container">



<label class="next" for="img-1"></label>



<label class="next" for="img-2"></label>



<label class="next" for="img-3"></label>


</div>


</div>


</div>

Los estilos CSS/CSS3 primarios para la presentación de diapositivas y sus controles.

[data-am-gallery] {
 position: relative;
 width: 100%;
 height: 100%;
 background-color: #fff;
}

[data-am-gallery] .image {

position: absolute;

top: 0;

bottom: 0;

left: 0;

right: 0;

opacity: 0;

-webkit-transition: opacity 1000ms ease;

transition: opacity 1000ms ease;

background-size: cover;

background-position: center;

background-repeat: no-repeat;
}

[data-am-gallery] input[type="radio"] {

position: fixed;

top: -9999px;
}

[data-am-gallery] input[type="radio"]:checked { /* This loop handles the image switching and dot active state */
}

[data-am-gallery] input[type="radio"]:checked:nth-child(5) ~ .images .image:nth-child(5) { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(5) ~ .navigation .dot:nth-child(5) { background-color: coral; }

[data-am-gallery] input[type="radio"]:checked:nth-child(5) ~ .navigation .dot:nth-child(5):hover { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(4) ~ .images .image:nth-child(4) { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(4) ~ .navigation .dot:nth-child(4) { background-color: coral; }

[data-am-gallery] input[type="radio"]:checked:nth-child(4) ~ .navigation .dot:nth-child(4):hover { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(3) ~ .images .image:nth-child(3) { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(3) ~ .navigation .dot:nth-child(3) { background-color: coral; }

[data-am-gallery] input[type="radio"]:checked:nth-child(3) ~ .navigation .dot:nth-child(3):hover { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(2) ~ .images .image:nth-child(2) { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(2) ~ .navigation .dot:nth-child(2) { background-color: coral; }

[data-am-gallery] input[type="radio"]:checked:nth-child(2) ~ .navigation .dot:nth-child(2):hover { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(1) ~ .images .image:nth-child(1) { opacity: 1; }

[data-am-gallery] input[type="radio"]:checked:nth-child(1) ~ .navigation .dot:nth-child(1) { background-color: coral; }

[data-am-gallery] input[type="radio"]:checked:nth-child(1) ~ .navigation .dot:nth-child(1):hover { opacity: 1; }

[data-am-gallery] .navigation {

position: absolute;

bottom: 15px;

left: 50%;

-webkit-transform: translateX(-50%);

transform: translateX(-50%);
}

[data-am-gallery] .dot {

display: inline-block;

width: 15px;

height: 15px;

margin: 0 2px;

border-radius: 50%;

background-color: rgba(255, 255, 255, 0.8);

cursor: pointer;

-webkit-transition: opacity 200ms ease;

transition: opacity 200ms ease;
}

[data-am-gallery] .dot:hover { opacity: 0.8; }

[data-am-gallery] .prev, [data-am-gallery] .next {

position: absolute;

display: none;

top: 0;

bottom: 0;

width: 100px;

cursor: pointer;

-webkit-transition: all 200ms ease;

transition: all 200ms ease;

font-family: sans-serif;
}

[data-am-gallery] .prev:before, [data-am-gallery] .next:before {

position: absolute;

top: 50%;

left: 50%;

-webkit-transform: translate(-50%, -50%);

transform: translate(-50%, -50%);

font-size: 3vw;

color: rgba(255, 255, 255, 0.5);
}

[data-am-gallery] .prev:hover, [data-am-gallery] .next:hover { background-color: rgba(255, 255, 255, 0.1); }

[data-am-gallery] .prev {

left: 0;

-webkit-transform: translateX(-100%);

transform: translateX(-100%);
}

[data-am-gallery] .prev:before { content: "❮"; }

[data-am-gallery] .next {

right: 0;

-webkit-transform: translateX(100%);

transform: translateX(100%);
}

[data-am-gallery] .next:before { content: "❯"; }

[data-am-gallery]:hover .prev {

-webkit-transform: translateX(0);

transform: translateX(0);
}

[data-am-gallery]:hover .next {

-webkit-transform: translateX(0);

transform: translateX(0);
}

El bucle CSS para generar modificadores en [Data-AM-Gallery] para el número de imágenes. Esto es necesario para controlar los botones anterior y siguiente.

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(5) ~ .prev-container .prev:nth-child(4) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(5) ~ .next-container .next:nth-child(1) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(4) ~ .prev-container .prev:nth-child(3) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(4) ~ .next-container .next:nth-child(5) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(3) ~ .prev-container .prev:nth-child(2) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(3) ~ .next-container .next:nth-child(4) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .prev-container .prev:nth-child(1) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .next-container .next:nth-child(3) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .prev-container .prev:nth-child(5) { display: block; }

[data-am-gallery~="5"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .next-container .next:nth-child(2) { display: block; }

[data-am-gallery~="4"] input[type="radio"]:nth-child(5), [data-am-gallery~="4"] .navigation .dot:nth-child(5), [data-am-gallery~="4"] .image:nth-child(5) { display: none !important; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(4) ~ .prev-container .prev:nth-child(3) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(4) ~ .next-container .next:nth-child(1) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(3) ~ .prev-container .prev:nth-child(2) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(3) ~ .next-container .next:nth-child(4) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .prev-container .prev:nth-child(1) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .next-container .next:nth-child(3) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .prev-container .prev:nth-child(4) { display: block; }

[data-am-gallery~="4"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .next-container .next:nth-child(2) { display: block; }

[data-am-gallery~="3"] input[type="radio"]:nth-child(5), [data-am-gallery~="3"] .navigation .dot:nth-child(5), [data-am-gallery~="3"] .image:nth-child(5) { display: none !important; }

[data-am-gallery~="3"] input[type="radio"]:nth-child(4), [data-am-gallery~="3"] .navigation .dot:nth-child(4), [data-am-gallery~="3"] .image:nth-child(4) { display: none !important; }

[data-am-gallery~="3"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(3) ~ .prev-container .prev:nth-child(2) { display: block; }

[data-am-gallery~="3"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(3) ~ .next-container .next:nth-child(1) { display: block; }

[data-am-gallery~="3"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .prev-container .prev:nth-child(1) { display: block; }

[data-am-gallery~="3"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .next-container .next:nth-child(3) { display: block; }

[data-am-gallery~="3"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .prev-container .prev:nth-child(3) { display: block; }

[data-am-gallery~="3"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .next-container .next:nth-child(2) { display: block; }

[data-am-gallery~="2"] input[type="radio"]:nth-child(5), [data-am-gallery~="2"] .navigation .dot:nth-child(5), [data-am-gallery~="2"] .image:nth-child(5) { display: none !important; }

[data-am-gallery~="2"] input[type="radio"]:nth-child(4), [data-am-gallery~="2"] .navigation .dot:nth-child(4), [data-am-gallery~="2"] .image:nth-child(4) { display: none !important; }

[data-am-gallery~="2"] input[type="radio"]:nth-child(3), [data-am-gallery~="2"] .navigation .dot:nth-child(3), [data-am-gallery~="2"] .image:nth-child(3) { display: none !important; }

[data-am-gallery~="2"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .prev-container .prev:nth-child(1) { display: block; }

[data-am-gallery~="2"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(2) ~ .next-container .next:nth-child(1) { display: block; }

[data-am-gallery~="2"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .prev-container .prev:nth-child(2) { display: block; }

[data-am-gallery~="2"][data-am-gallery~="next-prev-navigation"] input[type="radio"]:checked:nth-child(1) ~ .next-container .next:nth-child(2) { display: block; }

[data-am-gallery~="1"] .navigation { display: none; }

Te puede interesar: