最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - CSS3 multiple background images from JavaScript - Stack Overflow

programmeradmin6浏览0评论

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 0
Add a ment  | 

1 Answer 1

Reset to default 9

backgroundImage 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 ";
发布评论

评论列表(0)

  1. 暂无评论