There is a parent div which has absolute positioning with a child having absolute positioning. My problem is to make the child div relative to the whole page not to its parent:
Example:
.parent {
position: absolute;
top: 10px;
left: 10px;
width: 100px;
height: 100px;
background-color: blue;
overflow: hidden;
animation: move 2s infinite;
}
.child {
position: fixed;
top: 5px;
left: 5px;
width: 50px;
height: 50px;
background-color: purple;
z-index: 2;
}
@keyframes move {
50% {
transform: translateX(25px);
}
}
<div class="parent">
<div class="child"></div>
</div>
The goal is to make the little purple div fixed in top left of screen and hidden when the big blue div blue move outside it. I tried sticky - fixed
with same result.