How do you use headroom.js with Bootstrap 3 navbar?

前端 未结 4 1395
难免孤独
难免孤独 2021-01-31 20:20

I found this JavaScript widget http://wicky.nillia.ms/headroom.js/ and I want to use it in a web application using Bootstrap 3. It doesn\'t seem to be working. Any suggestion o

相关标签:
4条回答
  • 2021-01-31 20:59

    Try this :

    <script type="text/javascript">
            $(".navbar-fixed-top").headroom();
    </script>
    

    Source : http://codeasp.net/blogs/raghav_khunger/microsoft-net/2314/how-to-use-headroom-js

    Demo : http://fiddle.jshell.net/raghav_khunger/d7QQ8/2/show/light/

    0 讨论(0)
  • 2021-01-31 21:02

    I tried all the above steps but it wasn't working until i added "!important" to the styles.So it became this: <style type="text/css"> .headroom {position: fixed;top: 0;left: 0;right: 0;transition: all .2s ease-in-out !important;} .headroom--unpinned {top: -100px !important;} .headroom--pinned {top: 0 !important;} </style> its working now :)

    0 讨论(0)
  • 2021-01-31 21:18

    I found the solution to the problem. You need to add this style.

    <style type="text/css">
    .headroom {position: fixed;top: 0;left: 0;right: 0;transition: all .2s ease-in-out;}
    .headroom--unpinned {top: -100px;}
    .headroom--pinned {top: 0;}
    </style>
    

    Source: http://codeasp.net/blogs/raghav_khunger/microsoft-net/2314/how-to-use-headroom-js

    Thanks Fox Genki for the source link.

    0 讨论(0)
  • 2021-01-31 21:23

    The styles in the accepted answer aren't required to get headroom.js to work w/ Twitter Bootstrap 3. Simply following the instructions will work with navbar-fixed-top. The main thing is that you assign styles to these classes, otherwise nothing appears to happen.

    .headroom--pinned {
        display: block;
    }
    .headroom--unpinned {
        display: none;
    }
    
    0 讨论(0)
提交回复
热议问题