JSFiddle - React, Tailwind, and code Playground
HTML
<div id="wrapper">
<div id="sideBar">Some content here
<!--Some content in your right column/sidebar-->
<div id="sticker">...This is scroll here </div>
</div>
<div id="mainContent">
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content here <br />
some content...
CSS
div#wrapper {
margin:0 auto;
width:500px;
background:#FFF;
}
div#mainContent {
width:160px;
padding:20px;
float:left;
}
div#sideBar {
width:130px;
padding:20px;
margin-left:30px;
float:left;
}
.clear {
clear:both;
}
div#sticker {
padding:20px;
margin:20px 0;
background:#AAA;
width:190px;
}
.stick {
position:fixed;
top:0px;
}
JavaScript
$(document).ready(function() {
var s = $("#sticker");
var pos = s.position();
$(window).scroll(function() {
var windowpos = $(window).scrollTop();
if (windowpos >= pos.top) {
s.addClass("stick");
} else {
s.removeClass("stick");
}
});
});