"Scroll scrollSpy"
Bootstrap 4.1.1 Snippet by ashum499

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>ScrollSpy</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="outersec"> <div class="left-col"> <div class="inner"> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 1</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 2</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 3</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 4</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 5</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 6</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 7</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 8</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 9</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> <div class="header-div"> <p class="heading sc-sp-data-dis">list item 10</p> <div class="data"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> </div> </div> <div class="right-col"> <div class="inner"> <ul> <li> <a href="" class="sc-sp-list">list 1</a> </li> <li> <a href="#" class="sc-sp-list">list 2</a> </li> <li> <a href="#" class="sc-sp-list">list 3</a> </li> <li> <a href="#" class="sc-sp-list">list 4</a> </li> <li> <a href="#" class="sc-sp-list">list 5</a> </li> <li> <a href="#" class="sc-sp-list">list 6</a> </li> <li> <a href="#" class="sc-sp-list">list 7</a> </li> <li> <a href="#" class="sc-sp-list">list 8</a> </li> <li> <a href="#" class="sc-sp-list">list 9</a> </li> <li> <a href="#" class="sc-sp-list">list 10</a> </li> </ul> </div> </div> </div> <script src="js/jquery.js"></script> <script src="js/script.js"></script> </body> </html>
* { box-sizing: border-box; } body { margin: 0; font-family: Calibri; font-size: 20px; height: 100vh; color: #333; } .outersec { width: 100%; padding: 15px 0; height: 100%; } .outersec>.left-col, .outersec>.right-col { height: 100%; display: inline-block; margin-right: -4px; vertical-align: top; } .outersec>.left-col>.inner, .outersec>.right-col>.inner { width: 100%; overflow: auto; } .outersec>.right-col>.inner { height: 100%; } .outersec>.right-col { width: 250px; border-left: 1px solid #444; padding: 0 15px; position: fixed; right: 0; } .outersec>.right-col ul { margin: 0; padding: 0; list-style: none; } .outersec>.right-col ul>li>a { display: inline-block; padding: 10px 15px; text-decoration: none; width: 100%; background-color: #efefef; margin-bottom: 10px; color: #333; } .outersec>.right-col ul>li.active a, .outersec>.right-col ul>li>a:hover { background-color: #333; color: #fff; } .outersec>.right-col ul>li:last-child>a { margin-bottom: 0; } .outersec>.left-col { width: calc(100% - 250px); padding: 0 15px; } .outersec>.left-col .heading { font-weight: 900; text-transform: uppercase; padding: 10px; border: 1px solid #000; background-color: gray; color: #fff; } .outersec>.left-col .heading.active { background-color: #333; }
$(function () { // ADDING DATA (function () { var inc = 0; $('.sc-sp-data-dis').each(function () { $(this).attr('data-scsp', "data" + inc) inc++; }); })(); (function () { var inc = 0; $('.sc-sp-list').each(function (ev) { $(this).attr('data-scsp', "data" + inc) inc++; }); })(); $(window).on("load scroll", function () { var windowScroll = $(this).scrollTop(); $(".sc-sp-data-dis").each(function () { var thisOffsetTop = Math.round($(this).offset().top - 30); if (windowScroll >= thisOffsetTop) { var thisAttr = $(this).attr('data-scsp'); $('.sc-sp-list').parent().removeClass("active"); $('.sc-sp-list[data-scsp="' + thisAttr + '"]').parent().addClass("active"); } }); }); $('.sc-sp-list').click(function (ev) { ev.preventDefault(); var thisAttr = $(this).attr("data-scsp"); var scrollTo = $('.sc-sp-data-dis[data-scsp="' + thisAttr + '"]').offset().top; $(this).parent().addClass("active").siblings().removeClass("active"); $(".sc-sp-data-dis").removeClass("active"); $('.sc-sp-data-dis[data-scsp="' + thisAttr + '"]').addClass("active"); $('html, body').animate({ scrollTop: scrollTo - 5 }, 150); }); });

Related: See More


Questions / Comments:

One of the only ScrollSpy, Responsive Sidebar Navs that actually work with Bootstrap 4 AND Dotnetnuke. Its highly customizable and code although lacking in documentation is well structured.

mark-ideasoftware () - 3 years ago - Reply 0


One of the only ScrollSpy, Responsive Sidebar Navs that actually work with Bootstrap 4 AND Dotnetnuke. Its highly customizable and code although lacking in documentation is well structured.

mark-ideasoftware () - 3 years ago - Reply 0


One of the only ScrollSpy, Responsive Sidebar Navs that actually work with Bootstrap 4 AND Dotnetnuke. Its highly customizable and code although lacking in documentation is well structured.

mark-ideasoftware () - 3 years ago - Reply 0


One of the only ScrollSpy, Responsive Sidebar Navs that actually work with Bootstrap 4 AND Dotnetnuke. Its highly customizeable and code although lacking in documentation is well structured.

mark-ideasoftware () - 3 years ago - Reply 0


One of the only ScrollSpy, Responsive Sidebar Navs that actually work with Bootstrap 4 AND Dotnetnuke. Its highly customizeable and code although lacking in documentation is well structured.

mark-ideasoftware () - 3 years ago - Reply 0