The following HTML shows a scrollable resizable div with a button and a further content div in it.
<!DOCTYPE html>
<html>
<head>
<style>
.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;
}
</style>
</head>
<body>
<div class="container">
<button class="fixed">Test</button>
<div class="content">
texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext
</div>
</div>
</body>
</html>
The button should be fixed at the top right corner in the div. This works fine for resizing, however, when I scroll, the button moves too. How can I fix this?