jquery - Bootstrap Scroll spy Not working -
i tried use affix , bootstrap scrollspy using fiddle achieved affix can't make scrollpsy working. here code please let me know if missing. here demo fiddle
side menu
<div class="col-md-3 scrollspy"> <ul id="nav-side" class="nav-side hidden-xs hidden-sm affix-top" data-spy="affix"> <li class=""><a href="#web-design">web design</a></li> <li class=""><a href="#web-development">web development</a> <ul class="nav-side"> <li class=""><a href="#ruby"><span class="fa fa-angle-double-right"></span>ruby</a></li> <li class=""><a href="#python"><span class="fa fa-angle-double-right"></span>python</a></li> </ul> </li> <li class=""><a href="#graphic-design">graphic design</a></li> </ul> </div>
main content
<div class="col-md-9" data-spy="scroll" data-target=".scrollspy" id="spyonthis"> <section id="web-design"> <h2><span class="fa fa-edit"></span> web design</h2> <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. aenean commodo ligula eget dolor. </p> </section><!--end of #web-design--> <section id="web-development"> <h2><span class="fa fa-edit"></span> web development</h2> <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. aenean commodo ligula eget dolor. aenean massa. </p> <section id="ruby"> <h3>ruby</h3> <p>maecenas nec odio et ante tincidunt tempus. donec vitae sapien ut libero venenatis faucibus. </p> </section><!--end of #ruby--> <section id="python"> <h3>python</h3> <p>maecenas nec odio et ante tincidunt tempus. donec vitae sapien ut libero venenatis faucibus. </p> </section><!--end of #python--> </section><!--end of #web-devlopment--> <section id="graphic-design"> <h2><span class="fa fa-edit"></span> graphic design</h2> <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. aenean commodo ligula eget dolor.</p> </section><!--end of #graphic-design--> </div>
js
$('#nav-side').affix({ offset: { top: $('#nav-side').offset().top, bottom: ($('footer').outerheight(true) + $('.application').outerheight(true)) + 40 } });
css
.nav-side li a:hover, .nav-side li a:focus { background: #86c5da; } .nav-side .active { font-weight: bold; background: #72bcd4; } .nav-side .nav-side { display: none; } .nav-side .active .nav-side { display: block; } .nav-side .nav-side { font-weight: normal; font-size: .85em; } .nav-side .nav-side span { margin: 0 5px 0 2px; } .nav-side .nav-side .active a, .nav-side .nav-side .active:hover a, .nav-side .nav-side .active:focus { font-weight: bold; padding-left: 30px; border-left: 5px solid black; } .nav-side .nav-side .active span, .nav-side .nav-side .active:hover span, .nav-side .nav-side .active:focus span { display: none; } .application { border-top: 1px solid #c1e1ec; } #nav-side.affix-top { position: relative; } #nav-side.affix { top: 100px; position: fixed; } #nav-side.affix, #nav-side.affix-bottom { width: 213px; } #nav-side.affix-bottom { position: absolute; }
Comments
Post a Comment