JSFiddle - React, Tailwind, and code Playground
by e-swoosh Limited
HTML
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p><p>test</p>
<p>test</p>
<div id="topnav">Funky Nv <div class="logo">LOGO HERE</div></div>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p><p>test</p>
<p>test</p>
<p>test</p><p>test</p>
<p>test</p>
<p>test</p><p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
CSS
#topnav{
background:#e4e4e4;
min-height:42px;
width:100%;
}
.fixed{position:fixed;top:0;width:100%;}
#topnav.fixed{background:red;}
#topnav .logo{display:none;}
#topnav.fixed .logo{display:block;}
JavaScript
var offset=0;
$(document).ready(function(){
offset_of_nv = $('#topnav').offset().top;
});
$(window).scroll(function() {
if($(this).scrollTop() > offset_of_nv) {
$('#topnav').addClass("fixed");
} else {
$('#topnav').removeClass("fixed");
}
});