1.0.0 • Published 8 years ago
shared-background v1.0.0
Shared Background
Introduction
Shared Background is a Javascript script that aims to help developer to use the same background image between multiple elements. We also provide a jQuery integration.
Usage
Javascript version
<div id="shared">
<div class="panel"></div>
<div class="panel"></div>
<div class="panel"></div>
</div>
<script src="dist/shared-background.min.js"></script>
<script>
var container = document.getElementById('shared'); //the DOM element that contain all panels
var backgroundImageUrl = 'http://lorempixel.com/1024/500/nature'; //the background image to use
new SharedBackground(container, backgroundImageUrl);
</script>
jQuery version
<div data-shared-background="http://lorempixel.com/1024/500/nature">
<div class="panel"></div>
<div class="panel"></div>
<div class="panel"></div>
</div>
<script src="dist/shared-background.jquery.min.js"></script>
or
<div class="shared">
<div class="panel"></div>
<div class="panel"></div>
<div class="panel"></div>
</div>
<script src="dist/shared-background.jquery.min.js"></script>
<script>
$(function(){
$('.shared').sharedBackground('http://lorempixel.com/1024/500/nature');
});
</script>
1.0.0
8 years ago