JSFiddle - React, Tailwind, and code Playground

by dactivo

HTML

<div class="myPopUp">ESTO SOY YO</div>
a
sd
asd

asd
a
sd
asd<br/><br/>
<br/><br/><br/><br/><br/><br/>

<br/>
<br/>
<br/>
asdasd

<br/>
<br/><br/><br/><br/>
<br/>
<br/>

CSS

body{
height:30px;overflow:scroll
}
.myPopUp{position:relative;
border:1px solid black;width:200px;height:30px
}

JavaScript

$(window).scroll(function () {
  var top = ($(window).height() - $('.myPopUp').height()) / 2 + $(window).scrollTop();

  $('.myPopUp').animate({ top: top }, 200);
});