JSFiddle - React, Tailwind, and code Playground
HTML
<div class="moving-article">
<div class="container">
<header class="fixed-header">FIXED HEADER</header>
<ul>
<li>SCROLL</li>
<li>SCROLL</li>
<li>SCROLL</li>
</ul>
</div>
</div>
CSS
.moving-article {
height: 150px;
width: 75%;
overflow-x: scroll;
}
.fixed-header {
background: rgba(0,0,0,0.5);
width: 50%;
text-align: center;
line-height: 40px;
position: absolute;
top: 0;
left: 0;
}
.container{
width: 1000px;
}
/* IGNORE BELOW CSS - JUST FOR PRESENTATION */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'arial', cursive;
color: #fff;
}
.unmoving-article {
-webkit-font-smoothing: subpixel-antialiased; /* avoid font get thinner */
border: solid 10px #fff;
height: 150px;
overflow: scroll;
position: relative;
width:50%;
}
li {
background: #7081FF;
min-height: 100px;
text-align: center;
vertical-align: middle;
display: -webkit-flex;
-webkit-align-items: center;
-webkit-justify-content: center;
}
li:nth-of-type(2) {
background: #434d99;
}
JavaScript
var leftOffset = parseInt($(".fixed-header").css('left'));
$(window).scroll(function(){
$('.fixed-header').css({
'left': $(this).scrollLeft() + leftOffset
});
});