You’re looking for position: fixed.
From MDN:
Fixed positioning is similar to absolute positioning, with the exception that the element’s containing block is the viewport. This is often used to create a floating element that stays in the same position even after scrolling the page.
Notice it doesn’t work when…
(…) one of its ancestors has a
transform,perspective, orfilterproperty set to something other thannone.