I'm trying to make a popup that has an expanded area that appears from under it. The width of the popup is variable, so the expanded area must be a child of the popup element in order to always appear in the correct position, so it's z-index
should be -1. The white button should move to the right as it toggles the expansion, so it should be a child of the expanded area, but that way it can't appear over the main popup, since its parent has a z-index
of -1.
Ideally it should look something like this: https://cdn.discordapp.com/attachments/496805607454670888/558592164452499456/unknown.png
.container {
display: flex;
align-items: center;
justify-content: center;
}
.popup {
position: relative;
background: lightgray;
}
.popup-content {
width: 100px;
height: 100px;
}
.popup-expanded-container {
position: absolute;
top: 10px;
bottom: 10px;
left: calc(100% - 30px);
background-color: darkgray;
z-index: -1;
padding: 10px;
padding-left: 40px;
padding-top: 40px;
}
.popup-expanded-content {
width: 0px;
}
.expanded-toggle-btn {
position: absolute;
top: 5px;
right: 5px;
width: 30px;
height: 30px;
background-color: white;
border-radius: 50%;
}
<div class="container">
<div class="popup">
<div class="popup-content"></div>
<div class="popup-expanded-container">
<div class="expanded-toggle-btn"></div>
<div class="popup-expanded-content">
</div>
</div>
</div>
</div>