"On scroll Fix Header"
Bootstrap 4.1.1 Snippet by Arjunverma

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <header class="clearHeader"> </header> <div class="wrapper"> </div> </div> </div>
.header{ height: 200px; background-color: rgba(107,107,107,0.66); position: fixed; top:200; width: 100%; } .darkHeader { height: 100px; } .wrapper { height:2000px; }
$(window).scroll(function() { var scroll = $(window).scrollTop(); //>=, not <= if (scroll >= 500) { //clearHeader, not clearheader - caps H $(".header").addClass("darkHeader"); }else { $(".header").removeClass("darkHeader"); } }); //missing );

Related: See More


Questions / Comments: