Codeconvey
  • Home
  • Tutorials
    • CSS Slideshow
    • CSS Navigation
    • Modal & Popup
    • Hover Effects
    • HTML Forms
    • Layout
  • CSS Animation
  • How To
  • Resources
No Result
View All Result
Codeconvey
No Result
View All Result

Basic Parallax Background Effect in Javascript – BBng.js

Ashfaq Ahmed by Ashfaq Ahmed
January 13, 2020
in Parallax Scrolling
0
Basic Parallax Background Effect
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Today, We come up with a parallax background js plugin called BBng.js. It’s a very basic plugin to create a clean and nice-looking effect by using different content and image layers.

There is no doubt that both video parallax effect and background photos are trending and the mostly one-page site uses it.

But it is important to make parallax animation perfectly and should be lightweight. Because if it doesn’t then you may frustrate with slow website speed.

The BBng.js plugin is a small and zero-dependency JavaScript library that applies a refined parallax scrolling impact on background pictures. Based mostly on the HTML5 window.requestAnimationFrame API and has assist for offset and callback.

The purpose of using this tiny plugin to make the effect lightweight as much as possible. Another thing, It is very easy to implement and all we need to add a javascript file and define DIV elements with background images.

And you are done. That’s It.

The parallax scrolling is a new web trend for websites where the background images moved at a different speed than the foreground content background while scrolling.

How To Create a Parallax Scrolling Effect using JS

To start making parallax scrolling, All you need to add a bbng.js in your document. When you download the plugin file, You will also find a demo.css file that you don’t need to add. It’s only for creating a demo page to style it.

<script src = 'src/bbng.js'></script>

Next, there are two different elements available which you can define in your web page. The div with class name “blank” allows you to add content and for a div element with class name “foo” is provide you effect.

You only need to define the inline style and add background by using the background-image

<div class = 'blank'></div>
<div class = 'foo' style = 'background-image: url("images/bg1.jpg");'></div>

There is no need to the stylesheet to create the effect but to style the element and text. You can add a few lines. We did add the following CSS.

<style>
* {
   margin: 0;
   padding: 0;
}
html {
   height: 100%;
}
body {
   height:100%;
}
.blank p {
   color: #fff;
   padding: 4em;
   font-size: 22px;
   text-align: center;
   line-height: 35px;
}
.foo {
   width: 100%;
   height: 50%;
}
.blank {
  height: 350px;
}
</style>

You need to Initialize the big library.

<script>
var bbng = new BBNG({ className : 'foo', offset: 2 });
window.onload = function() {
  bbng.render();
}
</script>

Activate the parallax scroll impact.

window.onload = operate()
Tags: Parallax Background
Buy Me A Coffee Demo Download
Previous Post

Video Parallax Effect with HTML Background Video

Next Post

Pure CSS: Animated CSS3 Checkbox Styling

Next Post
Animated CSS3 Checkbox Styling

Pure CSS: Animated CSS3 Checkbox Styling

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe More Tutorials

Subscribe to our mailing list to receives monthly updates direct to your inbox!

You might also like

CSS Flip Animation on Hover – Flipping Card

CSS Flip Animation on Hover – Flipping Card

January 7, 2020
CSS Percentage Circle

Pure CSS Percentage Circle With Animation

January 21, 2023
CSS Glow Button Hover Effect

Pure CSS Button Shine/Glow Effect on Hover

December 23, 2019
Easy to Apply CSS Image Hover Transition Effects

CSS Image Hover Transition Effects

December 5, 2019
Codeconvey

© 2023 Codeconvey.com - All rights reserved.

Navigate Site

  • Home
  • About Us
  • Contact us
  • License
  • Disclaimer
  • DMCA
  • Terms & Conditions

Follow Us

No Result
View All Result
  • Home
  • CSS Animation
  • CSS Navigation
  • HTML Forms
  • Hover Effects
  • CSS Slideshow
  • Layout
  • Modal & Popup
  • How To
  • Resources

© 2023 Codeconvey.com - All rights reserved.