This is the structure of my HTML:
<div class='header-wrapper'>
<div class='title'>Title</div>
</div>
<div class='some-wide-content'>
</div>
Let's imagine a scenario where the browser window is 500px wide. In this case, I want the header-wrapper to also be 500px wide with a colored background. The title should be horizontally centered within this 500px width. On the other hand, some-wide-content consists of a large table with a width of 1000px. Due to the size of the table, the body of the page extends beyond the browser window, allowing users to scroll horizontally. However, I do not want the header-wrapper to move when scrolling horizontally. Using position: fixed
for header-wrapper is not feasible since it needs to move vertically along with the page.
So, how can I create an element that remains fixed horizontally even when the rest of the page scrolls horizontally?
EDIT: Currently, my workaround involves making only the some-wide-content section scrollable so that users aren't scrolling the entire page horizontally. However, this solution is not ideal as there are specific reasons why I need the entire page to scroll horizontally.