Elegant menu transition in Bootstrap

I like the fixed menu, that stays in place when your scroll the content, but I have seen a few websites do a cool transition between opaque and transparent background, as well as changing other attributes, depending on whether you are at the “top” or if you are scrolling.

The JS is the important part, that toggles the “scrolled” class

$(function () {
  $(document).scroll(function () {
	  var $nav = $(".navbar-fixed-top");
	  $nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height());

Edit in JSFiddle

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.