In the HTML below, you will find a resizable and scrollable div containing a button and additional content.
.container {
width: 100%;
max-width: 100%;
height: 150px;
position: relative;
overflow: auto;
resize: both;
white-space: nowrap;
background: lightgray;
}
.container .fixed {
position: absolute;
right: 5px;
top: 5px;
}
<div class="container">
<button class="fixed">Test</button>
<div class="content">
texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
text<br>
</div>
</div>
The button is intended to remain fixed at the top right corner of the div. Although it stays in place while resizing, it moves when scrolling. How can this issue be addressed?