I've implemented bootstrap, if you goto: http://twitter.github.com/bootstrap/javascript.html#affix
Im tyring to apply an affix to the left side bar where when I scroll down the side bar stays with the scroll in view. I cannot get this to work. I tried everything. Any ideas or tricks I need to do to get this working?
I tried the data element and javascript way, neither work. I do have the bootstrap.js, bootstrap.cs, and bootstrap-responsive.cs implemented as well.
<div class="container">
<!-- Docs nav
================================================== -->
<div class="row">
<div class="span3 bs-docs-sidebar" data-spy="affix" data-offset-top="200" >
<ul class="nav nav-list bs-docs-sidenav">
<li><a href="#AccountId"><i class="icon-chevron-right"></i>My Account</a></li>
<li><a href="#tutorialid"><i class="icon-chevron-right"></i>My Tutorials</a></li>
<li><a href="#buttonDropdowns"><i class="icon-chevron-right"></i>My Articles</a></li>
<li><a href="#navs"><i class="icon-chevron-right"></i>Help</a></li>
</ul>
</div>
<div class="span9">
<!-- Typography
================================================== -->
<section id="AccountId">
<div class="page-header">
<h1>My Account</h1>
</div>
<div class="bs-docs-example">
<h3><b>Change Password</b></h3>
<div>
<label>Current Password</label>
<input type="text" />
<label>New Password</label>
<input type="text" />
<label>Confirm Password</label>
<input type="text" />
<br />
<input type="button" class="btn btn-primary" value="Submit" />
</div>
<h3><b>Tutorial Settings</b></h3>
<div>
<label>Current Password</label>
<input type="text" />
<label>New Password</label>
<input type="text" />
<label>Confirm Password</label>
<input type="text" />
<br />
<input type="button" class="btn btn-primary" value="Submit" />
</div>
<h3><b>Article Settings</b></h3>
<div>
<label>Current Password</label>
<input type="text" />
<label>New Password</label>
<input type="text" />
<label>Confirm Password</label>
<input type="text" />
<br />
<input type="button" class="btn btn-primary" value="Submit" />
</div>
</div>
</section>@* Tutorials *@
<section id="tutorialid">
<div class="page-header">
<h1>My Tutorials</h1>
</div>
<div class="bs-docs-example"></div>
</section>
</div>
</div>
</div>
It doesn't work because you are adding the affix to the div
while you should add it to the ul
.
If you inspect the source code of the Twitter Bootstrap Javascript page that's how they do it.
I tried to do it with your code and it works :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With