JSFiddle - React, Tailwind, and code Playground
HTML
<div class="popupContent">popupContent</div>
CSS
.popupContent{border:solid black 1px;padding:5px;}
JavaScript
$.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
return this;
}
$(".popupContent").center();