JSFiddle - React, Tailwind, and code Playground
HTML
<div id="fixed">
je ne scrolle pas
</div>
<div id="screen">
</div>
CSS
#screen {
height: 2000px;
}
#fixed {
width: 200px;
height:80px;
border: solid 1px green;
}
.fixme {
position: fixed;
top: 50px;
left: 50px;
}
JavaScript
$(function(){
for (i=0;i<100;i++){
$('#screen').append($('<p/>').html('ligne '+i))
}
$(window).on('scroll', function(){
if ($(window).scrollTop()>100){
$('#fixed').addClass('fixme')
}
else{
$('#fixed').removeClass('fixme')
}
})
})