"Nav click page scrolling with header fixed"
Bootstrap 4.1.1 Snippet by ranjit1602

<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 class="static-header"> <img src="https://s.cdpn.io/profiles/user/328575/80.jpg?4" height="40" height="auto"/> <nav> <a href="#section1">Section 1</a> <a href="#section2">Section 2</a> <a href="#section3">Section 3</a> <a href="#section4">Section 4</a> </nav> </header> <header class="fixed-header"> <div class="fheader__container"> <img src="https://s.cdpn.io/profiles/user/328575/80.jpg?4" width="30px" height="auto"/> <nav> <a href="#section1">Section 1</a> <a href="#section2">Section 2</a> <a href="#section3">Section 3</a> <a href="#section4">Section 4</a> </nav> </div> </header> <div class="container__content"> <div id="section1" class="section1"> <h1>Section 1</h1> </div> <div id="section2" class="section2"> <h1>Section 2</h1> </div> <div id="section3" class="section3"> <h1>Section 3</h1> </div> <div id="section4" class="section4"> <h1>Section 4</h1> </div> </div> <footer> </footer>
body { font-family: "Open Sans", sans-serif; font-weight: 300; margin: 0; padding: 0 15px 30px 15px; box-sizing: border-box; background: #f3f3f3; } body .static-header { max-width: 900px; overflow: hidden; box-sizing: border-box; margin: 20px auto; text-align: center; } body .static-header img { margin: 0 auto; } body .static-header nav { padding: 20px 0 0; max-width: 400px; margin: 0 auto; } body .static-header nav a { display: inline-block; color: #666; text-decoration: none; font-size: 14px; cursor: pointer; } body .static-header nav a:not(:last-of-type) { padding-right: 30px; } body .static-header nav a:hover { color: #333; } body .fixed-header { display: none; position: fixed; top: 0; background: #fff; margin: 0 -15px; width: 100%; border-bottom: 1px solid #ccc; box-sizing: border-box; box-shadow: 0px 0px 10px 0 rgba(0, 0, 0, 0.5); opacity: 0.9; z-index: 100; } body .fixed-header .fheader__container { max-width: 900px; padding: 15px 30px; margin: 0 auto; overflow: hidden; box-sizing: border-box; } body .fixed-header .fheader__container img { float: left; height: 30px; width: auto; } body .fixed-header .fheader__container nav { padding: 5px 0; max-width: 400px; float: right; text-align: right; } body .fixed-header .fheader__container nav a { display: inline-block; color: #666; text-decoration: none; font-size: 14px; cursor: pointer; } body .fixed-header .fheader__container nav a:not(:last-of-type) { padding-right: 15px; } body .fixed-header .fheader__container nav a:hover { color: #333; } body .container__content { margin: 0 auto; max-width: 900px; background: rgba(255, 255, 255, 0.8); box-sizing: border-box; min-height: 1000px; overflow: hidden; padding: 15px; clear: both; } body .container__content > div { min-height: 500px; display: block; overflow: hidden; } body .container__content > div h1 { text-align: center; line-height: 500px; color: #666; margin: 0; } body .container__content > div.section1 { background: #ffd6cd; } body .container__content > div.section2 { background: #ddebfd; } body .container__content > div.section3 { background: #ffd6cd; } body .container__content > div.section4 { background: #ddebfd; }
$(document).ready(function(){ $('a[href^="#"]').on('click',function (e) { e.preventDefault(); var target = this.hash; var $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 900, 'swing', function () { window.location.hash = target; }); }); }); $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 200) { $(".fixed-header").slideDown(); } else { $(".fixed-header").slideUp(); } });

Related: See More


Questions / Comments: