I created this piece of code containing a gold container that scrolls vertically. On top on it there is another container that should be always visible.
I tried using position absolute
and sticky
but I don't understand why it is not in the right position.
When I scroll down, it should be visibile always on top...
<div style="border: 1px solid black;">
<div
style="position: relative; height: 500px; max-height: 500px; overflow-y: auto;"
>
<div style="width:100%; height: 500px;">
<svg x="0" y="0" width="100%" height="800">
<rect x="0" y="0" width="100%" height="800" fill="gold"></rect>
</svg>
</div>
<div
style="position: absolute; top: 0; width: 100%; height: 112px; background-color: rgba(0, 0, 0, 0.2);"
>
<div
style="width: fit-content; padding: 15px; color: white; border: 1px solid white; margin: 20px 10px;"
>
Button text
</div>
</div>
</div>
</div>