JSFiddle - React, Tailwind, and code Playground
HTML
<div id="head"> i </div>
<div id="subHead"> can </div>
<div id="content"> haz </div>
CSS
#head, #subHead{
position: fixed;
height: 80px;
width: 100%;
display: block;
background: #c00;
left: 0;
top: 0;
z-index: 10;
}
#subHead{
z-index: 4;
background: #cd0;
top: 80px;
}
#content{
position: relative;
z-index: 6;
height: 1000px;
background: #eee;
margin-top: 160px;
}
JavaScript
window.onscroll = function(ev){
var subHead = document.getElementById('subHead'),
topHeight = document.getElementById('head').offsetHeight,
scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
subHead.style.top = (topHeight - scrollTop / 4) + 'px';
};