"Responsive sticky header navigation by Bootstrap 4.0.0"
Bootstrap 4.0.0 Snippet by Noman1416

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.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 ----------> <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <header> <nav class="navbar navbar-expand-lg navbar-light bg-danger text-light py-3 main-nav"> <div class="container"> <a class="navbar-brand" href="index.html"><img src="https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjhjPfY_97WAhWCOI8KHSvHA34QjRwIBw&url=http%3A%2F%2Fpluspng.com%2Fhp-png-1793.html&psig=AOvVaw38ZFiKrvcpgGwQUMhu9Vx8&ust=1507481987906950" alt="Logo"></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="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse " id="navbarSupportedContent"> <ul class="navbar-nav ml-auto"> <li class="nav-item active"> <a class="nav-link text-uppercase" href="index.html">Home <span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link text-uppercase" href="#story">about</a> </li> <li class="nav-item"> <a class="nav-link text-uppercase" href="#expertise">expertise</a> </li> <li class="nav-item"> <a class="nav-link text-uppercase" href="#team">teams</a> </li> <li class="nav-item"> <a class="nav-link text-uppercase" href="#works">works</a> </li> <li class="nav-item"> <a class="nav-link text-uppercase" href="#people-say">pepole say</a> </li> <li class="nav-item"> <a class="nav-link text-uppercase" href="#contact">contact</a> </li> </ul> </div> </div> </nav> </header> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script> <script src="js/custom.js"></script> </body> </html>
header .main-nav{ position: fixed; top: 0; left: 0; width: 100%; z-index: 4000; } header .main-nav-scrolled{ background-color: rgba(0,0,0,0.4); } .navbar-light .navbar-nav .nav-link{ color: #fff; } .navbar-light .navbar-nav .active .nav-link{ color: #00e0d0; } /*for test*/ body{ height: 400px; }
var mn = $(".main-nav"); mns = "main-nav-scrolled"; hdr = $('header').height(); $(window).scroll(function() { if( $(this).scrollTop() > hdr ) { mn.addClass(mns); } else { mn.removeClass(mns); } });

Related: See More


Questions / Comments: