JSFiddle - React, Tailwind, and code Playground
by juErik
HTML
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<div id='eins'>
<div id='zwei'>
</div>
</div>
CSS
#eins{
margin: 50px;
width: 300px;
height: 200px;
background-color: #808000;
}
#zwei{
width: 50px;
height: 50px;
background-color: #ff0000;
}
JavaScript
/* ******************************************************* centriert Object in der Bildschirm mitte */
jQuery.fn.centerWindow = 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;
}
// *******************************************************
$('#zwei').centerWindow();