JSFiddle - React, Tailwind, and code Playground
HTML
<div style="height: 200vh;">
<div id="back-top"></div>
</div>
CSS
#back-top {
position: fixed;
width: 100px;
height: 100px;
opacity:0;
background-color: black;
}
JavaScript
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('#back-top').fadeTo("fast", 0.6);
} else {
$('#back-top').fadeTo("fast", 0);
}
});
$('#back-top').hover(function () {
$(this).fadeTo("slow", 1);
}, function () {
$(this).fadeTo("slow", 0.6);
});