background-image

Set background image for given element

Set background image for given element

$ npm install background-image

Call it with a DOM element or a selector, and a image url:

backgroundImage = require('background-image')
 
backgroundImage('.container', 'http://foo.com/foo.jpg')

It'll show the image as a cover background. You can pass following options as third parameter to customize:

{
  repeat: 'no-repeat',
  position: 'center center',
  size: 'cover'
}