05scrollspy.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-COMPATIBLE" content="IE=Edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. <title>Bootstrap Plugins</title>
  8. <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
  9. <!--[if lt IE 9]>
  10. <script src="../js/html5shiv.3-7-0.js"></script>
  11. <script src="../js/respond.1-4-2.min.js"></script>
  12. <![endif]-->
  13. <style type="text/css">
  14. .scrollspy-example {
  15. position: relative;
  16. height: 200px;
  17. margin-top: 10px;
  18. overflow: auto;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div class="container">
  24. <div id="navbarExample" class="navbar navbar-default" role="navigation">
  25. <div class="container-fluid">
  26. <div class="navbar-header">
  27. <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbarLinks">
  28. <span class="icon-bar">A</span>
  29. <span class="icon-bar">B</span>
  30. <span class="icon-bar">C</span>
  31. </button>
  32. <a class="navbar-brand" href="#">SitePoint</a>
  33. </div>
  34. <div class="collapse navbar-collapse navbarLinks">
  35. <ul class="nav navbar-nav">
  36. <li class="active"><a href="#home">Home</a></li>
  37. <li class=""><a href="#about">About</a></li>
  38. <li class=""><a href="#contact">Contact Us</a></li>
  39. <li class=""><a href="#map">Map</a></li>
  40. </ul>
  41. </div>
  42. </div>
  43. </div>
  44. <div data-spy="scroll" data-target="#navbarExample" data-offset="0" class="scrollspy-example">
  45. <h4 id="home">Home</h4>
  46. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
  47. tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  48. veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  49. commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
  50. velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  51. cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
  52. est laborum</p>
  53. <h4 id="about">About</h4>
  54. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
  55. tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  56. veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  57. commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
  58. velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  59. cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
  60. est laborum</p>
  61. <h4 id="contact">Contact us</h4>
  62. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
  63. tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  64. veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  65. commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
  66. velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  67. cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
  68. est laborum</p>
  69. <h4 id="map">Map</h4>
  70. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
  71. tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  72. veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  73. commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
  74. velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  75. cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
  76. est laborum</p>
  77. </div>
  78. <!-- https://ajax.googleapis.com/ajax/libs/jquery/1.11.1.jquery.min.js -->
  79. <script src="../js/jquery-1.11.2.min.js"></script>
  80. <script src="../js/bootstrap.js"></script>
  81. <script type="text/javascript">
  82. /*
  83. $(".scrollspy-example").scrollspy({
  84. 'target' : '#navbarExample'
  85. });
  86. $(".scrollspy-example").scrollspy('refresh');
  87. */
  88. $('#navbarExample').on('activate.bs.scrollspy', function () {
  89. console.log('New link highlighted', this.id);
  90. });
  91. </script>
  92. </div>
  93. </body>
  94. </html>