Scrollspy Tutorial With Bootstrap

By @kanasamania1/25/2018utopian-io

f_14364303231462.jpg

Ever guns you open a website and there is a link menu navigation that will update or look active when we are in a certain part of our time scroll? This can be called a Scrollspy. Scrollspy is usually suitable for web singling page, to let users know where the position or section is being read by them.

Well Bootstrap turned out to have tools or plugins like this. Using CSS and Javascript from Bootstrap, today we will make a scrollshy. This tutorial will a simple way to do Scrollspy, so you know easily how implement it in web documents.

In this tutorial we will need 2 elements, the first element is the navigation menu. And the second is Content (can be articles, sections, div). So let's get started.

Create a new HTML document, and add name (up to you) demoscrollspy.html

Import Bootstraps.

The first thing we should do is import the bootstrap, both css and javascript. We also need to use jquery.

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

The element we need in Scrollspy is navigation (

7

comments