I came across a strange issue while trying to position an position: absolute popup in my project.
Regarding position: absolute MDN says:
The element is removed from the normal document flow, and no space is created for the element in the page layout.
Unfortunately, in the example below positioning the element with right: 0 and transform: translateX(100%) creates additional space outside the body as if the element were to be position: relative. This doesn't happen if we do left: 0 and transform: translateX(-100%).
.parent {
width: 100%;
height: 100vh;
border: 1px solid red;
background-color: magenta;
}
.child {
position: absolute;
transform: translateX(100%);
width: 100px;
height: 50%;
border: 1px solid black;
right: 0;
background-color: yellow;
}
<div class="parent">
<div class="child"></div>
</div>
Here's a link to an example of the issue https://jsbin.com/fikonusayi/edit?html,css,output
Is this a browser bug or is this an (un)expected feature?
P.S. Discovered in Chrome and Safari.