How can one define multiple background images in CSS3 programmatically via JavaScript?
The obvious idea:
var element = document.createElement( 'div' );
element.style.backgroundImage = "url('a.png') 0 100%, url('b.png') 50px 50px ";
doesn't work - it must be something simple, but what?
How can one define multiple background images in CSS3 programmatically via JavaScript?
The obvious idea:
var element = document.createElement( 'div' );
element.style.backgroundImage = "url('a.png') 0 100%, url('b.png') 50px 50px ";
doesn't work - it must be something simple, but what?
Share Improve this question asked Mar 9, 2013 at 23:38 qdotqdot 6,3455 gold badges45 silver badges100 bronze badges 01 Answer
Reset to default 9backgroundImage
is for background image only if you are setting multiple background properties in one you have to use background
.
element.style.background = "url('a.png') 0 100%, url('b.png') 50px 50px ";