2.0.2 • Published 7 years ago

goodbackground.js v2.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

goodbackground.js npm version

Very simple jQuery modern JavaScript improver for your background image.

Install via npm (recommended):

$ npm install goodbackground.js --save

Add goodbackground.js to your project:

require('goodbackground.js')

Old way to install

Download goodbackground.min.js and place file to your project template (before close body tag):

<!-- goodbackground.js minify version -->
<script src="/path/to/goodbackground.min.js"></script>

Usage

Add data attribute background-image with full path to your background image (any DOM elements):

<div data-background-image="/path/to/images/picture.jpg">
  ...
</div>

Done!

Customize

By default, goodbackground.js search for DOM elements on page with a required data attribute background-image and apply this default params:

OptionCSS PropertyAvailable VariablesDefault value
positionbackground-positionleft, right, center, top, bottomcenter
repeatbackground-repeatrepeat, repeat-x, repeat-y, no-repeat, initial, inheritno-repeat
sizebackground-sizeauto, length, cover, contain, intial, inheritcover

If you want to set another background params or overwrite exists, just add to your container data attributes with this CCS properties:

OptionCSS PropertyAvailable VariablesDefault value
attachmentbackground-attachmentscroll, fixed, local, initial, inheritnone
clipbackground-clipborder-box, padding-box, content-box, initial, inheritnone
colorbackground-colorhex/rgb color, transparent, initial, inheritnone
originbackground-originpadding-box, border-box, content-box, initial, inheritnone

For example:

<div
  data-background-image="/path/to/images/picture.jpg"
  data-background-size="contain"
  data-background-position="bottom right"
  data-background-repeat="repeat"
  ...>
</div>

Developers

Development and maintenance of goodbackground.js project engaged by Vikky Shostak (Koddr). If you want to write a «thank you» or ask us about something, use this e-mail.

Your help

If you want help, we will be glad reviews about goodbackground.js on personal blogs (including Twitter), online media and/or specialized IT-portals. Thank you!

License

The MIT License (MIT)