"Bootstrap Sticky Header"
Bootstrap 4.1.1 Snippet by Hoss

<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="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!--================Header Area =================--> <header class="main_header_area"> <div class="header_top"> <div class="container"> <div class="header_top_inner"> <div class="float-left"> <ul class="list_style"> <li><a href="tel:1238952582">+1800 456 7890</a></li> <li><a href="tel:1238952582">+1800 456 7890</a></li> </ul> </div> <div class="float-right"> <ul class="nav list_style header_top_menu"> <li><i class="fa fa-facebook"></i></li> <li><i class="fa fa-google"></i></li> <li><i class="fa fa-instagram"></i></li> </ul> </div> </div> </div> </div> <nav class="navbar navbar-expand-lg navbar-light"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <a class="navbar-brand" href="index.html">Manali</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="nav navbar-nav ml-auto"> <li class="nav-item active"><a href="index.html" class="nav-link">Home</a></li> <li class="nav-item submenu dropdown"> <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About Us</a> <ul class="dropdown-menu"> <li><a href="#">Our Company</a></li> <li><a href="#">Team</a></li> </ul> </li> <li class="nav-item"><a href="#" class="nav-link">Products</a></li> <li class="nav-item"><a href="#" class="nav-link">What's New</a></li> <li class="nav-item submenu dropdown"> <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Resources</a> <ul class="dropdown-menu"> <li><a href="#">Resources</a></li> <li><a href="#">Colleteral</a></li> </ul> </li> <li class="nav-item"><a href="#" class="nav-link">Enquiry</a></li> <li class="nav-item"><a href="#" class="nav-link">Conatct Us</a></li> </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav> </header> <!--================Header Area =================--> <div class="container"> <p>What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. </div>
/*---------------------------------------------------- */ /*----------------------------------------------------*/ /* main_header_area css ==============================================*/ .main_header_area { position: absolute; width: 100%; z-index: 25; background: #fff; border-bottom: 1px solid rgba(255, 255, 255, 0.08); top: 0px; } .header_top .header_top_inner { font: 500 14px/30px "Poppins", sans-serif; color: #fff; overflow: hidden; border-bottom: 1px solid rgba(255, 255, 255, 0.149); } .header_top .header_top_inner ul li { display: inline-block; color: #fff; } .header_top{ background-color: #030502; color: #fff; } .header_top .header_top_inner ul li a { color: #fff; position: relative; } .header_top .header_top_inner ul li a:before { content: ""; position: absolute; width: 2px; height: 12px; left: 15px; top: 50%; left: -18px; margin-top: -6px; background: #000; -webkit-transform: rotate(18deg); -ms-transform: rotate(18deg); transform: rotate(18deg); } .header_top .header_top_inner ul li a:hover { color: #0D2891; } .header_top .header_top_inner ul li:first-child a:before { display: none; } .header_top .header_top_inner ul li + li { margin-left: 30px; } .header_top.h_top_two .header_top_inner ul li a { color: #948ea1; } .header_top.h_top_two .header_top_inner ul li a:before { background: #948ea1; } .navbar { padding: 0px; } .navbar .navbar-brand img + img { display: none; } .navbar .nav .nav-item a { font: 500 16px/40px "Poppins", sans-serif; color: #000; padding: 0px; } .navbar .nav .nav-item a:after { display: none; } .navbar .nav .nav-item:hover a, .navbar .nav .nav-item.active a { color: #0D2891; } .navbar .nav .nav-item.submenu { position: relative; } .navbar .nav .nav-item.submenu ul { border: none; padding: 0px 15px; border-radius: 0px; -webkit-box-shadow: none; box-shadow: none; background: transparent; margin: 0px; } @media (min-width: 992px) { .navbar .nav .nav-item.submenu ul { position: absolute; top: 100%; left: -40px; min-width: 200px; background: #fff; -webkit-box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); text-align: left; opacity: 0; -webkit-transition: all 300ms ease-in; -o-transition: all 300ms ease-in; transition: all 300ms ease-in; visibility: hidden; display: block; border: none; padding: 0px; border-radius: 0px; } } .navbar .nav .nav-item.submenu ul:before { content: ""; width: 0; height: 0; border-style: solid; border-width: 10px 10px 0 10px; border-color: #eeeeee transparent transparent transparent; position: absolute; right: 24px; top: 45px; z-index: 3; opacity: 0; -webkit-transition: all 400ms linear; -o-transition: all 400ms linear; transition: all 400ms linear; } .navbar .nav .nav-item.submenu ul li { display: block; float: none; margin-right: 0px; margin-left: 0px; } .navbar .nav .nav-item.submenu ul li a { line-height: 45px; color: #242424; font-family: "Poppins", sans-serif; font-weight: 500; font-size: 15px; padding: 0px 30px; text-transform: capitalize; -webkit-transition: all 150ms linear; -o-transition: all 150ms linear; transition: all 150ms linear; display: block; } .navbar .nav .nav-item.submenu ul li:last-child { border-bottom: none; } .navbar .nav .nav-item.submenu ul li:hover a { background: #f2f2f2; color: #4466d7; } @media (min-width: 992px) { .navbar .nav .nav-item.submenu:hover ul { left: 0px; visibility: visible; opacity: 1; } } .navbar .nav .nav-item + li { margin-left: 30px; } .navbar .nav .search_dropdown { -webkit-transition: all 0.3s ease-in; -o-transition: all 0.3s ease-in; transition: all 0.3s ease-in; position: relative; } .navbar .nav .search_dropdown a:before { content: ""; width: 1px; height: 15px; background: rgba(255, 255, 255, 0.249); left: 0; top: 0px; position: relative; display: inline-block; margin: 0px 20px; } .navbar .nav .search_dropdown .search { background: #fff; height: 35px; padding: 0px; line-height: 35px; border-radius: 0px; width: 200px; position: absolute; top: 100%; right: 0; z-index: 1000; opacity: 0; visibility: hidden; -webkit-transform: translateX(20px); -ms-transform: translateX(20px); transform: translateX(20px); -webkit-transition: all 0.3s ease-in; -o-transition: all 0.3s ease-in; transition: all 0.3s ease-in; } .navbar .nav .search_dropdown .search li .search-form { padding: 1px 10px 0px; } .navbar .nav .search_dropdown .search li .search-form .form-control { background: transparent; border: 0; font: 400 14px/31px "Open Sans", sans-serif; padding: 0px 0px 1px 7px; -webkit-box-shadow: none; box-shadow: none; color: rgba(64, 64, 64, 0.5); font-style: italic; text-shadow: none; border-radius: 0px; } .navbar .nav .search_dropdown .search li .search-form .form-control.placeholder { color: rgba(64, 64, 64, 0.5); } .navbar .nav .search_dropdown .search li .search-form .form-control:-moz-placeholder { color: rgba(64, 64, 64, 0.5); } .navbar .nav .search_dropdown .search li .search-form .form-control::-moz-placeholder { color: rgba(64, 64, 64, 0.5); } .navbar .nav .search_dropdown .search li .search-form .form-control::-webkit-input-placeholder { color: rgba(64, 64, 64, 0.5); } .navbar .nav .search_dropdown .search li .search-form .input-group-addon { background: transparent; border: 0px; padding: 0px; border-radius: 0px; } .navbar .nav .search_dropdown .search li .search-form .input-group-addon button { background: transparent; border: 0px; color: rgba(64, 64, 64, 0.5); } .navbar .nav .search_dropdown.open .search { opacity: 1; -webkit-transform: translateX(0); -ms-transform: translateX(0); transform: translateX(0); visibility: visible; } .navbar-toggler[aria-expanded="false"] span:nth-child(2) { opacity: 1; } .navbar-toggler[aria-expanded="true"] span:nth-child(2) { opacity: 0; } .navbar-toggler[aria-expanded="true"] span:first-child { -webkit-transform: rotate(-45deg); -ms-transform: rotate(-45deg); transform: rotate(-45deg); position: relative; top: 7.7px; } .navbar-toggler[aria-expanded="true"] span:last-child { -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); bottom: 4px; position: relative; } .navbar-toggler { border: 0px; padding: 0px; cursor: pointer; } .navbar-toggler span { display: block; width: 25px; height: 2px; background: #fff; margin: auto; margin-bottom: 4px; -webkit-transition: all 400ms linear; -o-transition: all 400ms linear; transition: all 400ms linear; cursor: pointer; } .navbar-toggler span:last-child { margin-bottom: 0px; } /*===================== main_header_area_two css ===================*/ .main_header_area_two { background: transparent; } /*============== main_header_area_three css ================*/ .main_header_area_three { position: absolute; width: 100%; top: 0; left: 0; z-index: 25; } .header_top_two { padding: 14px 0px; } .header_top_two a { color: #fff; } .h_info a { font-size: 15px; line-height: 20px; font-family: "Poppins", sans-serif; } .h_info a i { padding-right: 10px; } .h_info a + a { margin-left: 36px; } .h_info a:hover { color: #0D2891; } .h_social_icon a { font-size: 18px; margin-left: 18px; } .h_social_icon a:hover { color: #0D2891; } .nav_three { border-radius: 5px; background: #182557; padding: 0px 40px; } .nav_three .nav .nav-item a { line-height: 95px; } /*=============== affix css ===============*/ .navbar_fixed { width: 100%; left: 0; top: -70px; background: #fff; position: fixed; -webkit-box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1); box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1); border-bottom: 0px; z-index: 999; -webkit-transform: translateY(70px); -ms-transform: translateY(70px); transform: translateY(70px); transition: background 100ms linear, -webkit-transform 500ms ease; -webkit-transition: background 100ms linear, -webkit-transform 500ms ease; -o-transition: transform 500ms ease, background 100msheader linear; transition: transform 500ms ease, background 100ms linear; transition: transform 500ms ease, background 100ms linear, -webkit-transform 500ms ease; -webkit-transition: transform 500ms ease, background 100ms linear; -webkit-backface-visibility: hidden; } .navbar_fixed .header_top, .navbar_fixed .header_top_two { display: none; } .navbar_fixed .navbar .navbar-brand img { display: none; } .navbar_fixed .navbar .navbar-brand img + img { display: block; } .navbar_fixed .navbar .nav .nav-item > a { color: #242424; line-height: 70px; } .navbar_fixed .navbar .nav .nav-item:hover > a, .navbar_fixed .navbar .nav .nav-item.active > a { color: #0D2891; } .navbar_fixed .navbar .navbar-toggler span { background: #0D2891; } .navbar_fixed.main_header_area_three { top: -70px; -webkit-transform: translateY(70px); -ms-transform: translateY(70px); transform: translateY(70px); transition: transform 300ms ease, background 100ms linear, -webkit-transform 300ms ease; border-radius: 0px; position: fixed; background: #fff; } .navbar_fixed.main_header_area_three .navbar { background: #fff; border-radius: 0px; } .navbar_fixed.main_header_area_three .navbar .nav .nav-item > a { line-height: 70px; }
$(document).ready(function(){ "use strict"; var nav_offset_top = $('header').height() + 100; //* Navbar Fixed function navbarFixed(){ if ( $('header').length ){ $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= nav_offset_top) { $("header").addClass("navbar_fixed"); } else { $("header").removeClass("navbar_fixed"); } }) } } navbarFixed(); });

Related: See More


Questions / Comments: