Slideshow di immagini in background con javascript html e css

Slideshow di immagini in background con javascript html e css

In questo post vedremo come creare uno Slideshow di immagini in background con javascript html e css da impostare come sfondo fullscreen di un sito web.


Slideshow di immagini in background con javascript html e css

Cominciamo con il foglio si stile css da assegnare al tag body

Creiamo la funzione javascript, con i relativi parametri, che si occuperà di visulizzare la slideshow di immagini in background

Questo il codice completo

Il codice è abbastanza commentato, per altri chiarimenti non esitate a scrivere nei commenti.

A presto 😉

2 commenti su “Slideshow di immagini in background con javascript html e css”

    1. Ciao Federico,

      per avere un effetto di transizione, tra le immagini, puoi aggiungere transition come proprietà del css legato al tag body:

      per un effetto fade tra le immagini dovrebbe andare bene aggiungere:

      transition: background 0.5s linear;
      

      sostituendo il codice, presente in questo post, con questo:

      [...]
      <style>
            body,html {  height: 100%; margin: 0; padding:0;}
            body{
              /* Center and scale the image nicely */
              background-position: center;
              background-repeat: no-repeat;
              -webkit-background-size: cover;
              -moz-background-size: cover;
              -o-background-size: cover;
              background-size: cover;
              
              transition: background 0.5s linear;
              -webkit-transition: background 1.5s linear;
              }
          </style>
      [...]
      

      Per maggiori info sulla proprietà transition ti rimando a questo link.

      Raffaele

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *