JSFiddle - React, Tailwind, and code Playground
HTML
<div class="fix">
<div class="relative">fixed content</div>
</div>
<div class="rel">relative content</div>
CSS
.fix{
position:fixed;
background-color: black;
color: white;
width: 100%;
top: 0 ;
left:0;
padding:20px;
box-sizing:border-box;
}
.fix .relative {
position: relative;
}
.rel {
position: relative;
width: 2000px;
}
JavaScript
$(window).on('scroll', function(e) {
var left = $(this).scrollLeft();
$('.fix .relative').css('left', -left);
});