"Awesome fixed header bootstarp 4 "
Bootstrap 4.1.1 Snippet by Shivamsemisetia

<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 ----------> <header> <nav class="navbar navbar-expand-lg top_navbar navbar-dark navbar-light" id="top-navbar"> <div class="container"> <a class="navbar-brand" href=""><img src="img/logo.png" alt="" class="img-fluid" />logo</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#ftco-nav" aria-controls="ftco-nav" aria-expanded="false" aria-label="Toggle navigation"> <span class="fa fa-bars"></span> </button> <div class="collapse navbar-collapse" id="ftco-nav"> <ul class="navbar-nav ml-auto"> <li class="nav-item active"><a href="#" class="nav-link">Home</a></li> <li class="nav-item"><a href="#" class="nav-link">Segments</a></li> <li class="nav-item"><a href="#" class="nav-link">Portfolio</a></li> <li class="nav-item"><a href="#" class="nav-link">Press Releases</a></li> </ul> </div> </div> </nav> </header>
body{ height:5000px; } /* ========================================================================== Navbar Section ========================================================================== */ .navbar-light { background: transparent !important; position: absolute; top: 0; left: 0; right: 0; z-index: 3; padding: 0; margin: 0; } .bg_red{ background: #de2d26 !important; position: relative; } .navbar-light .navbar-brand { color: #fff; padding: 15px; } .navbar-light .navbar-nav .nav-item .nav-link { font-size: 18px; padding-top: 0.9rem; padding-bottom: 0.9rem; padding-left: 20px; padding-right: 20px; font-weight: 500; opacity: 1 !important; } .navbar-light .navbar-nav .nav-item .nav-link:hover { color: #fff; } .navbar-light .navbar-nav .nav-item .dropdown-menu { border: none; background: #fff; -moz-transition: all 0.3s ease; -o-transition: all 0.3s ease; -webkit-transition: all 0.3s ease; -ms-transition: all 0.3s ease; transition: all 0.3s ease; border-radius: 0; -webkit-box-shadow: 0px 10px 34px -20px rgba(0, 0, 0, 0.41); -moz-box-shadow: 0px 10px 34px -20px rgba(0, 0, 0, 0.41); box-shadow: 0px 10px 34px -20px rgba(0, 0, 0, 0.41); } .navbar-light .navbar-nav .nav-item .dropdown-menu .dropdown-item { font-size: 13px; color: rgba(0, 0, 0, 0.7); } .navbar-light .navbar-nav .nav-item .dropdown-menu .dropdown-item:hover, .navbar-light .navbar-nav .nav-item .dropdown-menu .dropdown-item:focus { color: #000000; background: transparent; } .navbar-light .navbar-nav .nav-item.ftco-seperator { position: relative; margin-left: 20px; padding-left: 20px; } .navbar-light .navbar-nav .nav-item.ftco-seperator:before { position: absolute; content: ""; top: 10px; bottom: 10px; left: 0; width: 2px; background: rgba(255, 255, 255, 0.05); } .navbar-light .navbar-nav .nav-item.cta a { color: #fff; border: 1px solid rgba(255, 255, 255, 0.4); padding-top: 0.5rem; padding-bottom: 0.5rem; padding-left: 20px; padding-right: 20px; margin-top: 4px; -webkit-border-radius: 30px; -moz-border-radius: 30px; -ms-border-radius: 30px; border-radius: 30px; } .navbar-light .navbar-nav .nav-item.cta a span { display: inline-block; color: #fff; } .navbar-light .navbar-nav .nav-item.cta a:hover { background: #ffcdcd; border: 1px solid #ffcdcd; } .navbar-light .navbar-nav .nav-item.cta.cta-colored span { border-color: #ffcdcd; } .navbar-light .navbar-nav .nav-item.active a { //color: rgb(222, 45, 38) !important; } .navbar.navbar-expand-lg.top_navbar.navbar-dark.navbar-light .nav-item a { color: #000; } .navbar-light .navbar-toggler { border: none; color: #962323 !important; cursor: pointer; padding-right: 15px; text-transform: uppercase; font-size: 25px; letter-spacing: 0.1em; } .navbar-light.scrolled { position: fixed; right: 0; left: 0; top: 0; margin-top: -130px; background: #fff !important; -webkit-box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); z-index:99; } .navbar-light.scrolled. .nav-item a { color: #de2d26; } .navbar-light.scrolled .nav-item.cta a { color: #fff !important; background: #de2d26; border: none !important; padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; padding-left: 20px; padding-right: 20px; margin-top: 6px !important; -webkit-border-radius: 30px; -moz-border-radius: 30px; -ms-border-radius: 30px; border-radius: 30px; } .navbar-light.scrolled .nav-item.cta a span { display: inline-block; color: #fff !important; } .navbar-light.scrolled .nav-item.cta.cta-colored span { border-color: #de2d26; } .navbar-light.scrolled .navbar-toggler { border: none; color: #de2d26 !important; cursor: pointer; padding-right: 15px; text-transform: uppercase; font-size: 25px; letter-spacing: 0.1em; } .navbar-light.scrolled .nav-link { padding-top: 0.9rem !important; padding-bottom: 0.9rem !important; color: #000000 !important; } .navbar-light.scrolled .nav-link.active { color: #de2d26 !important; } .navbar-light.scrolled.awake { margin-top: 0px; -webkit-transition: 0.3s all ease-out; -o-transition: 0.3s all ease-out; transition: 0.3s all ease-out; } .navbar-light.scrolled.sleep { -webkit-transition: 0.3s all ease-out; -o-transition: 0.3s all ease-out; transition: 0.3s all ease-out; } .navbar-light.scrolled .navbar-brand { color: #000000; } .navbar-light.scrolled .nav_btn{ background-color:#962323; color:#fff !important; box-shadow:0px 13px 27px #fff; } .navbar-brand { font-weight: 700; font-size: 20px; text-transform: uppercase; } .bor_l{ position:relative; } .bor_l:before{ border-left: 2px solid #821B1B; height: 30px; display: block; content: ''; position: absolute; left: 0; width: 2px; } .nav_btn{ background-color: #fff; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 18px; box-shadow:0px 13px 27px rgba(150,35,35,0.39); } .right_nav ul li a { font-size: 18px; padding-top: 0.9rem; padding-bottom: 0.9rem; padding-left: 20px; padding-right: 20px; color: #fff !important; font-weight: 500; opacity: 1 !important; text-decoration: underline !important; text-transform: uppercase; max-width: 200px; } @media (max-width: 767.98px) { .navbar-light.scrolled .navbar-nav { background: none; padding-left: 0 !important; padding-right: 0 !important; } } @media (max-width: 991.98px) { .navbar-light .navbar-nav .nav-item.ftco-seperator:before { display: none; } .navbar-light .navbar-nav .nav-item.ftco-seperator { padding-left: 0; margin-left: 0; } .navbar-light.scrolled .navbar-nav { background: none; border-radius: 0px; padding-left: 0rem !important; padding-right: 0rem !important; } .navbar-light { background: #fff !important; position: relative; top: 0; } .right_nav { display: none; } } @media (min-width: 768px) { .navbar-light .navbar-brand.navbar-brand-black { color: #000000; } .navbar-light .navbar-brand { color: #fff; } }
(function($) { // scroll var scrollWindow = function() { $(window).scroll(function(){ var $w = $(this), st = $w.scrollTop(), navbar = $('.top_navbar'), sd = $('.js-scroll-wrap'); if (st > 150) { if ( !navbar.hasClass('scrolled') ) { navbar.addClass('scrolled'); } } if (st < 150) { if ( navbar.hasClass('scrolled') ) { navbar.removeClass('scrolled sleep'); } } if ( st > 350 ) { if ( !navbar.hasClass('awake') ) { navbar.addClass('awake'); } if(sd.length > 0) { sd.addClass('sleep'); } } if ( st < 350 ) { if ( navbar.hasClass('awake') ) { navbar.removeClass('awake'); navbar.addClass('sleep'); } if(sd.length > 0) { sd.removeClass('sleep'); } } }); }; scrollWindow(); })(jQuery);

Related: See More


Questions / Comments: