I have a div with relative positioning that scrolls horizontally.
Within this div, I want to include a fixed element that also scrolls along with the parent div but remains at the top because the parent div is a child of a vertically scrolling div.
To better explain my point, I have created a codesandbox: https://codesandbox.io/s/strange-browser-mydzm
https://i.sstatic.net/TE7ub.png
The green div scrolls vertically, allowing both the red and blue divs to scroll simultaneously. The blue div can be scrolled horizontally while keeping the red div visible.
My goal is for the orange div (labeled RightPane) to scroll horizontally with the blue div, but remain fixed when the green div is scrolled vertically.
When setting the RightPane to positon: fixed
without specifying a top
property, it prevents vertical scrolling but also hinders horizontal scrolling.
Is there a way to achieve this using CSS alone?