TMan
TMan

Reputation: 4122

Using bootstrap side navbar

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>

Upvotes: 7

Views: 25368

Answers (2)

user2296553
user2296553

Reputation: 11

Go to the application.js, Line 19.

This will allow you to make custom padding for the sidenav to stop in the appropriate spot that you want it too.

Upvotes: 1

mokagio
mokagio

Reputation: 17481

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 :)

Upvotes: 5

Related Questions