I have a details element inside a div container which has relative position. Inside the details element there is another div that has position absolute. What I am trying to achieve is a expandable div container and details as it opens to show the content.
I outlined the containers with different colored borders so its easier to see but I can't get the containers to stretch.
How can I achieve this?
Thank you.
#container {
border: 1px solid red;
position: relative;
display: inline-block;
}
details {
border: 1px solid black;
height: fit-content;
display: inline-block;
}
#content {
position: absolute;
width: 100%;
height: fit-content;
}
<div id="container">
<details>
<summary>
title
</summary>
<div id="content">
some content<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
</details>
</div>