Is there a way to keep the submenu aligned under the button even when scrolling within the container div? Currently, it stays in the middle of the page.
div.container {
height: 200px;
width: 400px;
border: 1px solid black;
overflow-y: scroll;
}
.filter_container {
padding: 40px;
}
.index_filters_selected__NkclA {
display: flex;
gap: 5px;
align-items: center;
cursor: pointer;
background-color: #eceff4;
border-radius: 8px;
padding: 8px;
width: fit-content;
}
.modal_sub_menu {
position: absolute;
border: 1px solid #d6d9e5;
border-radius: 8px;
padding: 24px;
background-color: #ffffff;
z-index: 55;
}
<div class="container">
<div class="filter_container">
<div class="index_filters_selected__NkclA ">
<span>Subject</span>
<svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="transform: rotate(180deg);">
<path d="M2.25 5L6 8.75L9.75 5" stroke="#3D4252" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</div>
<div class="modal_sub_menu">
<form>
<div class="filters_forms_filters_form__SbQTV">
<label for="email_subject">
<div class="label">Subject </div>
<input type="text" placeholder="Subject" id="email_subject" class="" value="">
</label>
<div><button type="button" class="cancel_button">Cancel</button><button type="submit">Apply</button></div>
</div>
</form>
</div>
</div>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla</span>pidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
https://jsfiddle.net/mplante/1xpszjb2/53/
Thank you for your assistance!