This scrolls the background images behind modules or any other element you set it to.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the
leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
CSS
#content-container { background: url(/images/kb/2016/742/workplace.jpg) center center fixed; background-size: 100% auto; } /* Optional and is just for this demo */ #content-container { padding: 10px; } #content-container p { color: #999; font-size: 25px; }
JS
setTimeout(function() { (function($) { //---------------------------------------- /* Parallax Scrolling */ $(document).ready( function() { // Manually adding settings to an element //$('#content-container').attr('data-type', 'background'); //$('#content-container').attr('data-speed', '3'); // Rules based adding settings to an element if ($( "#content-container" ).hasClass( "parallax-background" )) { $('#jsn-content-top-below').attr('data-type', 'background'); $('#jsn-content-top-below').attr('data-speed', '3'); } /* Trigger the Parallax Scrolling */ $('div[data-type="background"]').each(function(){ var $bgobj = $(this); // assigning the object $window = $(window); $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // Put together our final background position var coords = '50% '+ yPos + 'px'; // Move the background $bgobj.css({ backgroundPosition: coords }); }); }); }); //---------------------------------------- })(jQuery); }, 0);
HTML
<div id="content-container" class="parallax-background"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer</p> <p>took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the</p> <p>leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release</p> <p>of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </div>