CSS3 - Multi Background

Multi sfondo

La proprietà CSS Multi background viene utilizzata per aggiungere una o più immagini alla volta senza codice HTML, possiamo aggiungere immagini secondo il nostro requisito.Una sintassi di esempio di immagini multi background è la seguente:

#multibackground {
   background-image: url(/css/images/logo.png), url(/css/images/border.png);
   background-position: left top, left top;
   background-repeat: no-repeat, repeat;
   padding: 75px;
}

I valori più comunemente usati sono mostrati di seguito:

Sr.No. Valore e descrizione
1

background

Utilizzato per impostare tutte le proprietà dell'immagine di sfondo in una sezione

2

background-clip

Utilizzato per dichiarare l'area di pittura dello sfondo

3

background-image

Utilizzato per specificare l'immagine di sfondo

4

background-origin

Utilizzato per specificare la posizione delle immagini di sfondo

5

background-size

Utilizzato per specificare la dimensione delle immagini di sfondo

Esempio

Di seguito è riportato l'esempio che mostra le immagini di sfondo multiplo.

<html>
   <head>
      <style>
         #multibackground {
            background-image: url(/css/images/logo.png), url(/css/images/border.png);
            background-position: left top, left top;
            background-repeat: no-repeat, repeat;
            padding: 75px;
         }
      </style>
   </head>

   <body>
   
      <div id = "multibackground">
         <h1>www.tutorialspoint.com</h1>
         <p>
            Tutorials Point originated from the idea that there exists a class of 
            readers who respond better to online content and prefer to learn new 
            skills at their own pace from the comforts of their drawing rooms. 
            The journey commenced with a single tutorial on HTML in  2006 and elated 
            by the response it generated, we worked our way to adding fresh tutorials 
            to our repository which now proudly flaunts a wealth of tutorials and 
            allied articles on topics ranging from programming languages to web designing 
            to academics and much more..
         </p>
      </div>
      
   </body>
</html>

Produrrà il seguente risultato:

Dimensione dello sfondo multiplo

La proprietà Multi background è accettata per aggiungere dimensioni diverse per immagini diverse.

#multibackground {
   background: url(/css/imalges/logo.png) left top no-repeat, url(/css/images/boarder.png) right bottom no-repeat, url(/css/images/css.gif) left top repeat;
   background-size: 50px, 130px, auto;
}

Come mostrato sopra un esempio, ogni immagine ha dimensioni specifiche come 50px, 130px e dimensioni automatiche.