JSFiddle - React, Tailwind, and code Playground
HTML
<div class="header">
<div id="background"></div>
<div id="labels">
labels here
</div>
</div>
<div class="content">
</div>
CSS
.header{
width:100%;
height:100px;
position:fixed;
top:0px;
z-index:3;
}
body{
margin:0px;
}
.header #background, .header #labels
{
position:absolute;
top:0px;
width:100%;
height:100%;
}
.header #labels{
background-color:transperent;
}
.header #background{
background-color:yellow;
display:none;
}
.content{
width:100%;
height:5000px;
background-color:green;
}
JavaScript
$(window).scroll(function() {
if ($(this).scrollTop() > 400) {
$( ".header #background" ).fadeIn();
} else {
console.log('there');
$( ".header #background" ).fadeOut();
}
});