11750

Bootstrap 3 navbar-fixed-top after scroll past fullscreen hero unit

I am currently having some issues trying to fix my navbar to the top of the page, BUT after the user scrolls past my fullscreen hero unit. I spent the last 2 days trying to figure it out and I cant find an exact answer anywhere!

<!-- Begin Hero --> <div class="jumbotron hero"> <!-- Content --> <div class="container center-vertically"> <hr> <p>We are Bolt & we like to <em>focus</em> on</p> <h1>Websites</h1> <hr> </div> </div> <!-- End Hero --> <!-- Begin Navigation --> <div class="navbar"> <div class="container"> <!-- Brand --> <a href="#" class="navbar-brand"><img class="logo" width="45" height="45" alt="lightning bolt logo" src="img/logo.png"></img></a> <!-- Mobile Navigation --> <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"> <span class="ion-navicon"></span> </button> <!-- Main Navigation --> <div class="collapse navbar-collapse navHeaderCollapse"> <ul class="nav navbar-nav navbar-right"> <li><a href="#">Home</a></li> <li><a href="#">Team</a></li> <li><a href="#">About</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> </div> <!-- End Navigation --> <!-- Begin Summary --> <section id="section1"> <div class="row summary"> <div class="container"> <!-- Content --> <div class="col-lg-10 col-lg-offset-1"> <h3>We create useable ui</h3> <hr> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer a elit turpis. Phasellus non varius mi. Nam bibendum mauris at sollicitudin lacinia. Vestibulum blandit nibh neque, id consequat mi vestibulum eu. Suspendisse potenti. Ut ac consequat nulla. Praesent tristique eleifend tincidunt.</p> <button class="btn btn-default bolt-button-default"> About us </button> </div> </div> </div> </section> <!-- End Summary -->

You can check out what I have so far here : http://jsfiddle.net/Q5Rv3/

Thank you!!!

Answer1:

I came up with the following solution which uses scroll property, not great to work with scroll but it does the work.

http://jsfiddle.net/Q5Rv3/2/

$(function () { $(document).on( 'scroll', function(){ console.log('scroll top : ' + $(window).scrollTop()); if($(window).scrollTop()>=$(".jumbotron").height()) { $(".navbar").addClass("navbar-fixed-top"); } if($(window).scrollTop()<$(".jumbotron").height()) { $(".navbar").removeClass("navbar-fixed-top"); } }); });

Recommend

  • No FileSystem for scheme: hdfs
  • Cayley db user and password protection over HTTP connections
  • Windows CreateFile slow when opening a large number of files
  • MFI Apple Program/Certification
  • How do I pass parameters to events? [closed]
  • Cyclic dependencies and interfaces in Golang
  • How to connect Gremlin Server to a remote Neo4j Database?
  • How to move a DOM element inside a closure
  • D3 - Drawing a path between DOM elements
  • Show message when Tform2 is created?
  • Bootstrap navbar stays expanded on route change
  • cordova build android throws error on Ubuntu 12.04
  • Mod rewrite redirection to another domain if file not exist
  • Jquery Show & ScrollTop (or ScrollTo)
  • jParallax trouble
  • CSS: How to fix overlapping divs
  • Unique SMS sender id?
  • window.onbeforeunload in javascript
  • Change navbar in bootstrap if user login
  • jQueryMobile, Ajax Navigation, and MVC
  • Which browser have this strange user agent? (IOS device)
  • Android Chronometer starts and stops but carries on counting when stopped
  • File loader changed image file name but not the file name in HTML file
  • Outputting SharePoint Hyperlink Column as URL
  • Floated image with variable width and heading with background image
  • Simulate click Geckofx vb,net
  • How to view images from protected folder with php?
  • Display images in Django
  • How to have background script and something similar to a default popup?
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Python urlparse: small issue
  • Jquery UI tool tip close icon
  • Android fill_parent issue
  • HTML download movie download link
  • Resize panoramic image to fixed size
  • Importing jscolor library in angular 2
  • jquery mobile loadPage not working
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • GridView Sorting works once only
  • How can I get HTML syntax highlighting in my editor for CakePHP?