I am facing a unique requirement where the parent div
has an absolute position
and the child div
also has an absolute position
. Inside the parent div
, I have set overflow: hidden
to hide the extra width of the child div
. However, this setup is not working as expected. I understand that the parent div
should ideally have a position: relative
, but due to the existing structure of my code, I am unable to switch the parent's position
from absolute
to relative
. Is there a workaround for this issue?
For reference, here is the example in a JSFiddle. The goal is to hide the light red box under the parent div
so that the child div
remains within the parent.
Below is the code snippet:
.wrapper {
position: absolute;
left: 100px;
top: 100px;
width: 400px;
height: 350px;
background: #666666;
padding: 10px;
}
.wrapper-inner {
position: absolute;
width: 450px;
height: 380px;
background: #fecccc;
}
<div class="wrapper">
<div class="wrapper-inner">
Content goes here
</div>
</div>