How to use the new affix plugin in twitter's bootstrap 2.1.0?

后端 未结 9 1623
梦谈多话
梦谈多话 2020-11-29 15:17

The bootstrap documentation on that topic is a little confusing to me. I want to achieve similar behaviour like in the docs with the affix navbar: The navbar is below a para

9条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 15:45

    Similar to the accepted answer, you can also do something like the following to do everything in one go:

    $('#nav').affix({
      offset: { top: $('#nav').offset().top }
    }).wrap(function() {
      return $('
    ', { height: $(this).outerHeight() }); });​

    This not only invokes the affix plugin, but will also wrap the affixed element in a div which will maintian the original height of the navbar.

提交回复
热议问题