Multiple Background Image
suggest changeMultiple background layers can be stacked on the same element.
#mydiv {
background-image: url(img_1.png), /* top image */
url(img_2.png), /* middle image */
url(img_3.png); /* bottom image */
background-position: right bottom,
left top,
right top;
background-repeat: no-repeat,
repeat,
no-repeat;
}
The first background in the list is painted on top and the last is painted at the back. img_1 is on top; img_2 and img_3 are behind it.
We can also use background shorthand property for this:
#mydiv {
background: url(img_1.png) right bottom no-repeat,
url(img_2.png) left top repeat,
url(img_3.png) right top no-repeat;
}
We can also stack images and gradients:
#mydiv {
background: url(image.png) right bottom no-repeat,
linear-gradient(to bottom, #fff 0%,#000 100%);
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents