-
-
CSS3 introduces a multi background function, which can be accessed through background-image Property to set multiple background images separated by commas. -
Sample code: .element {
background-image : url ( 'image1.jpg' ), url ( 'image2.jpg' );
/*Other Style Properties*/
}
-
-
Use pseudo elements (:: before or:: after): -
You can use pseudo elements to insert additional tags and set background images for them. -
Sample code: .element ::before {
content : '' ;
display : block;
background-image : url ( 'image1.jpg' );
/*Other Style Properties*/
} .element ::after {
content : ” ;
display : block;
background-image : url ( ‘image2.jpg’ );
/*Other Style Properties*/
}
-
-
Use HTML element nesting: -
Nest multiple elements together, and set a different background image for each element. -
Sample code: < div class = "parent-element" >
< div class = "child-element" style = "background-image: url('image1.jpg');" >
<!-- Content -->
</ div >
< div class = "child-element" style = "background-image: url('image2.jpg');" >
<!-- Content -->
</ div >
</ div >
-