"TEST: On-scroll header effects"
Bootstrap 3.3.0 Snippet by zysra

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!-- Camera image by: https://www.iconfinder.com/jackietran --> <!-- Fixed navbar --> <nav class="navbar navbar-inverse navbar-fixed-top normal" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><img class="img-responsive" src="https://cdn4.iconfinder.com/data/icons/adore/118/Camera.png" alt=""></a> </div> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav navbar-right"> <li class="active"><a href="#">Home</a> </li> <li><a href="#about">About</a> </li> <li><a href="#contact">Contact</a> </li> </ul> </div> <!--/.nav-collapse --> </div> <!--/.contatiner --> </nav> <!-- Main jumbotron for a primary marketing message or call to action --> <div class="jumbotron"> <div class="container"> <br> <h2>On-scroll<small> header effects</small></h2> <p> <p>Best viewed <a href="http://bootsnipp.com/iframe/z1Dx8" target="_blank">full screen</a></p> <p>??? Mobile dropdown now working... This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p> <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a> </p> </div> </div> <div class="container"> <!-- Example row of columns --> <div class="row"> <div class="col-md-4"> <h2>Heading</h2> <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p> <p><a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> <div class="col-md-4"> <h2>Heading</h2> <img src="http://i.imgur.com/DLScdiR.jpg" class="img-responsive" alt="bird" /> <br> <p><a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> <div class="col-md-4"> <h2>Heading</h2> <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper.</p> <p><a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> </div> <!-- /row --> <div class="container"> <!-- Example row of columns --> <div class="row"> <div class="col-md-4"> <h2>Heading</h2> <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p> <p><a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> <div class="col-md-4"> <h2>Heading</h2> <img src="http://i.imgur.com/DLScdiR.jpg" class="img-responsive" alt="bird" /> <br> <p><a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> <div class="col-md-4"> <h2>Heading</h2> <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper.</p> <p><a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> </div> <!-- /row --> <hr> <footer> <p>© Company 2014</p> </footer> </div> <!-- /container -->
/* Ref: Thanks to: http://span-tag.com/bootstrap-navbar/ */ body { min-height: 2000px; } /* added to .nav */ .normal { xheight: 75px; /* this causes drop down to lose color ??? */ -webkit-transition: 0.5s; -moz-transition: 0.5s; -ms-transition: 0.5s; transition: 0.5s; } .normal .navbar-right { padding-top: 12px; -webkit-transition: 0.5s; -moz-transition: 0.5s; -ms-transition: 0.5s; transition: 0.5s; } .navbar-brand { padding: 0px !important; } .navbar-brand img { padding: 5px; max-height: 75px; -webkit-transition: 0.5s; -moz-transition: 0.5s; -ms-transition: 0.5s; transition: 0.5s; } .shrink { height: 50px; -webkit-transition: 0.5s; -moz-transition: 0.5s; -ms-transition: 0.5s; transition: 0.5s; } .shrink .navbar-right { padding-top: 0px; -webkit-transition: 0.5s; -moz-transition: 0.5s; -ms-transition: 0.5s; transition: 0.5s; } .shrink .navbar-brand img { max-height: 50px; -webkit-transition: 0.5s; -moz-transition: 0.5s; -ms-transition: 0.5s; transition: 0.5s; }
$(window).scroll(function() { if ($(document).scrollTop() > 150) { $('.navbar').addClass('shrink'); } else { $('.navbar').removeClass('shrink'); } });

Related: See More


Questions / Comments: