Horje Website
Bs Scrollspy Affix2 Stacked – Bootstrap Affix – Bootstrap Affix – Bootstrap Code

Bs Scrollspy Affix2 Stacked – Bootstrap Affix

Bs Scrollspy Affix2 Stacked - Bootstrap Affix - Bootstrap Affix - Bootstrap Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Bootstrap Example</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  9. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
  10. <style>
  11. body {
  12. position: relative;
  13. }
  14. .affix {
  15. top: 20px;
  16. z-index: 9999 !important;
  17. }
  18. div.col-sm-9 div {
  19. height: 250px;
  20. font-size: 28px;
  21. }
  22. #section1 {color: #fff; background-color: #1E88E5;}
  23. #section2 {color: #fff; background-color: #673ab7;}
  24. #section3 {color: #fff; background-color: #ff9800;}
  25. #section41 {color: #fff; background-color: #00bcd4;}
  26. #section42 {color: #fff; background-color: #009688;}
  27. @media screen and (max-width: 810px) {
  28. #section1, #section2, #section3, #section41, #section42 {
  29. margin-left: 150px;
  30. }
  31. }
  32. </style>
  33. </head>
  34. <body data-spy="scroll" data-target="#myScrollspy" data-offset="15">
  35. <div class="container-fluid" style="background-color:#2196F3;color:#fff;height:220px;">
  36. <h1>Scrollspy & Affix Example</h1>
  37. <h3>Fixed vertical sidenav on scroll</h3>
  38. <p>Scroll this page to see how the navbar behaves with data-spy="affix" and data-spy="scrollspy".</p>
  39. <p>The left menu sticks the page after you have scrolled a specified amount of pixels, and the links in the menu are automatically updated based on scroll position.</p>
  40. </div>
  41. <br>
  42. <div class="container">
  43. <div class="row">
  44. <nav class="col-sm-3" id="myScrollspy">
  45. <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205">
  46. <li><a href="#section1">Section 1</a></li>
  47. <li><a href="#section2">Section 2</a></li>
  48. <li><a href="#section3">Section 3</a></li>
  49. <li class="dropdown">
  50. <a class="dropdown-toggle" data-toggle="dropdown" href="#">Section 4 <span class="caret"></span></a>
  51. <ul class="dropdown-menu">
  52. <li><a href="#section41">Section 4-1</a></li>
  53. <li><a href="#section42">Section 4-2</a></li>
  54. </ul>
  55. </li>
  56. </ul>
  57. </nav>
  58. <div class="col-sm-9">
  59. <div id="section1">
  60. <h1>Section 1</h1>
  61. <p>Try to scroll this section and look at the navigation list while scrolling!</p>
  62. </div>
  63. <div id="section2">
  64. <h1>Section 2</h1>
  65. <p>Try to scroll this section and look at the navigation list while scrolling!</p>
  66. </div>
  67. <div id="section3">
  68. <h1>Section 3</h1>
  69. <p>Try to scroll this section and look at the navigation list while scrolling!</p>
  70. </div>
  71. <div id="section41">
  72. <h1>Section 4-1</h1>
  73. <p>Try to scroll this section and look at the navigation list while scrolling!</p>
  74. </div>
  75. <div id="section42">
  76. <h1>Section 4-2</h1>
  77. <p>Try to scroll this section and look at the navigation list while scrolling!</p>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </body>
  83. </html>



Try Your Self ->



Published:
October 4, 2020
Author:
admin
Category:
Bootstrap 3, Bootstrap Source Code
Views:
15

This article was posted in Bootstrap 3, Bootstrap Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

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

 

Horje © 2011 - 2022