Coder Social home page Coder Social logo

scroll-spy's Introduction

scroll-spy

Scroll spy is small plain unobtrusive javascript that spies on the scrolling of a document window.

If you want to set the active link in your web page based on position of a name anchor as the page scrolls, this is the script for it.

Setup

If you know what a scroll-spy is already, all you want must be a script that achieves it without getting in your way.

Download the scroll-spy.js script.

Import the script into your html file using the <script> tag;

<script src="scroll-spy.js"></script>

Add attribute, data-scroll-spy to every named anchor you need to spy on, and you are done.

Note: Put <script> tags after your footer.

If you are new to scroll-spy, follow the rest of these instructions;

Setup your navigation link tags to point to your named anchors;

Add 'data-scroll-spy' attribute to your named anchor elements;

....
...

Create a special style for .active class in your stylesheet;

a.active{ background-color:#ccc; color:#333; }

You're all done.

scroll-spy's People

Contributors

laolusrael avatar

Watchers

James Cloos avatar Gauthier 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.