0

Today I learned about affix and the use of it with Bootstrap. I read all about it on the Bootstrap website and stack-overflow, and eventually checked How to use the new affix plugin in twitter's bootstrap 2.1.0? (see the jsfiddle link) as a good example.

But, I think I'm doing something fundamentally wrong. I added the right javascript to my index.php. I added the CSS to my stylesheet and just copy-pasted the nav-bar example from jsfiddle into my index.php. Nothing works.

HTML:

<div class="container">
    <div class="row">
        <!-- micro hero unit-->
        <div class="span12">
            <div class="well">
                 <h1> Some page title </h1> 
                <p>This is a website.</p>
                <p> <a class="btn btn-primary" href="#">Tell me more</a> 
                </p>
            </div>
        </div>
    </div>
</div>

JavaScript:

$(function () {
    $('#nav-wrapper').height($("#nav").height());
    $('#nav').affix({
        offset: {
            top: $('#nav').offset().top
        }
    });
});

Can someone tell me what I did wrong?

4
  • Are you using Bootstrap 3.0 or 2+? And we need to see some code to help you... Jul 30, 2014 at 20:29
  • I'm using Bootstrap 3.0. Jul 30, 2014 at 20:55
  • So a Bootstrap 2.1 guide will not suffice for a Bootstrap 3.0 build.. In other terms, you need to find a tutorial that will show you how to do what you want, but with Boostrap 3+ - You could start here: tutorialrepublic.com/twitter-bootstrap-tutorial/… Jul 30, 2014 at 20:55
  • How come you are using bootstrap 3 but using span12 which is definitely a bootstrap 2 class? Jul 30, 2014 at 21:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.