I am in the process of developing a popover system that consists of two main divs: the popover-container
and the popover
. The container is a small 0px
by 0px
sized div responsible for positioning relative to the page. My objective is to have the child popover
centered within its parent so that it appears in the middle.
<div class="popover-overlay">
<div class="popover-container" style="left: 40px;top: 40px;">
<div class="popover shadow_card-light"></div>
</div>
</div>
.popover-overlay {
position: fixed;
width: 100vw;
height: 100vh;
z-index: 500;
pointer-events: none;
}
.popover-container {
position: absolute;
width: 0px;
height: 0px;
}
.popover {
min-height: 20px;
min-width: 50px;
background: white;
border-radius: 3px;
overflow: hidden;
top: 10px;
}
The current placement of the elements resembles this view (the circle represents the container, while the rectangle symbolizes the actual popover visible to users)
https://i.sstatic.net/rzBB0.png
My desired goal is to achieve this type of alignment:
https://i.sstatic.net/EzXfz.png
I have experimented with various centering techniques such as flex centering and margin centering, but have not succeeded in achieving the desired outcome.