JSFiddle - React, Tailwind, and code Playground
HTML
<div id="top" class="shadow"></div>
CSS
body {
height: 2000px;
background-color: white;
}
body:before,
#top,
body:after {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 80px;
z-index: 9999;
background-color: yellow;
}
body:before{
content: '';
display: block;
z-index: 9997;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
body:after {
content: '';
display: block;
position: absolute; /* this needs to scroll */
background-color: white; /* match background of body */
top: 80px;
height: 3px; /* covers height of :before shadow */
z-index: 9998; /* overlap :before, moves on scroll */
}