How to set Popup child window center of parent window for different browsers
Please check the below code. Tried below code for child popup center.
code
var new_window;
function winOpen(){
width = window.innerWidth - 100;
height = window.innerHeight - 120;
var top = (screen.height - window.innerHeight) - 10;
var left = 100 / 3;
new_window=window.open('https://www.google.com',"_blank","toolbar=0, help:no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=" + width + ", height=" + height + ",top=" + top + ",left=" + left + "");
}
code
You can center elements inside the DOM in numerous ways, they are too many to list. However, usually it is done without JavaScript (your tag), but rather with CSS.
One way is by setting display:flex;, place-items:center and justify-content:center; on the parent;
Here is an example:
.parent {
width: 150px;
height: 150px;
background: #08f;
display: flex;
justify-content: center;
place-items: center;
}
.child {
width: 95px;
height: 95px;
background: #0a0;
}
<div class="parent">
<div class="child">Child</div>
</div>