Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Set background image for given element
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.npmignore
README.md
index.js
package.json
template.js
test.js

README.md

background-image

Set background image for given element. Example: http://requirebin.com/?gist=8075487

Install

$ npm install background-image

Usage

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'
}
Something went wrong with that request. Please try again.