Skip to content

Instantly share code, notes, and snippets.

@wilburhimself
Created January 14, 2011 00:02
Show Gist options
  • Select an option

  • Save wilburhimself/778880 to your computer and use it in GitHub Desktop.

Select an option

Save wilburhimself/778880 to your computer and use it in GitHub Desktop.
Background images with Less.js
.bg(@filename, @repeat: 'no-repeat', @left: '0px', @top: '0px') {
background: e(%('url(http://REPLACE WITH THE ABSOLUTE URL OF YOUR IMAGES FOLDER/%s) %s %s %s', @filename, @repeat, @left, @top));
}
/*
USAGE:
Assuming the background image file is bg.png and the ABSOLUTE URL for our images folder is http://example.com/images this mixing can be used in a declaration like:
.bg("bg.png", "repeat-x");
which will result in the following CSS:
background: url(http://example.com/images/bg.png) repeat-x 0 0;
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment