Giter Club home page Giter Club logo

jquery-background-image-scroll's Introduction

JQuery Background Image Scroll

A very simple, short, beautiful, and responsive JQuery plugin to scroll background image with page scroll. show1 show2

Live Demo

Get started

To start using JQuery Background Image Scroll you just need to add bgscroll.js to your page in the <head> section just after JQuery.

<script src='scripts/bgscroll.js'></script>

Now let's create <div> element with some background-image css property.

<head>
  <style>
    .background{
      width: 100vw;
      height: 70vh;
      background-image: url('background1.jpg');
      background-repeat: no-repeat;
      background-position: 50% 0%;
    }
  </style>
  <script src='scripts/jquery.js'></script>
  <script src='scripts/bgscroll.js'></script>
</head>

<body>
  <div class="background"></div>
</body>

And add JQuery's $(window).scroll() event in <head> and <script> section.

  <script>
    $(window).scroll(function(){
      $('.background').bgscroll();
    })
  </script>

That's all!

Options

You can define some options and change its default to your custom:

  • bgpositionx [INT between 0 and 100] X position of the background image measured in %. The value 50 is 50% (center of the image). Default: 50
  • direction [STRING 'top' or 'bottom'] The direction of scrolled image, top means: when the page is scrolled down, the background image is scrolled to top, bottom means: when the page is scrolled down, the background image is scrolled also to down. Default : 'top'
  • debug [BOOLEAN true or false] Output of current's image position in the browser console. Default : false
  • max - [INT between 0 and 100] the maximum position (in %) this background-image can move to. Default : '100'
  • min - [INT between 0 and 100] the minimum position (in %) this background-image can move from. Default : '0'

jquery-background-image-scroll's People

Contributors

hoffie420 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.