Create A Simple Background Parallax Effect Using jQuery - Download Create A Simple Background Parallax Effect Using jQuery

Download Create A Simple Background Parallax Effect Using jQuery

Posted on

This time I will share jQuery Plugin and tutorial about Create A Simple Background Parallax Effect Using jQuery, hope it will help you in programming stack.

Create A Simple Background Parallax Effect Using jQuery - Download Create A Simple Background Parallax Effect Using jQuery
File Size: 2.47 KB
Views Total: 2422
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A minimalist jQuery solution to implement a smooth on-scroll background image parallax effect on a position:relative container.

How to use it:

1. Create a DIV element on your webpage.

1 <div class="bg"></div>

2. Add a background image to the DIV and make it position:relative.

1 .bg {
2   position: relative;
3   z-index: -1;
4   height: 500px;
5   background-image: url('bg.jpg');
6   background-repeat: no-repeat;
7   background-size: cover;
8   background-size: 100% 100%;
9 }

3. Load the needed jQuery library in your webpage.

1 <script src="//code.jquery.com/jquery-1.11.3.js"></script>

4. Enable the parallax scrolling effect on the DIV element.

1 $(document).ready(function() {
2   $(window).on('scroll', function() {
3     yPos = window.pageYOffset;
4     shift = yPos * 0.8 + 'px';
5     $('.bg').css('top', shift);
6   });
7 });

This awesome jQuery plugin is developed by captainmoha. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net