How can I make a floating panel, taller than the screen height, in an even taller page, such that the panel always remains visible, yet scrolls enough to display all parts of it?
This strikes me as similar to the more common "panel that stays in one spot", but with a bonus challenge: since my magic panel is taller than the window, anchoring the top of the panel at the top of the screen (or, indeed, anywhere on the screen) means that the lower regions of the panel can never be displayed.
There may be other ways to meet the goal, but FWIW what I envision is
- When the page is scrolled to the top, the top of the panel is at the top of its display area.
- When the page is scrolled down a bit, the panel stays in sync with it, scrolling down pixel-for-pixel—it behaves
position:static
(the default). - When things are scrolled down far enough to expose the bottom of the panel, it pins there in the ordinary "stays in one spot" style, allowing the page to scroll down further while keeping the bottom of the panel visible and immobile—it becomes
position:fixed
.
I guess #2 could also be proportional scrolling, if that's possible, so that when the window scrolls down, say, 30% of its full travel, the panel also scrolls down 30% of its travel.
Concretely, suppose the page height is 1000 lines, the panel height is 200 lines, and the window height is 100 lines.
- At the top, line 1 of the page is at the top of the window, and line 1 of the panel is at the top of the window.
- Scroll down a bit, and line 10 of each is at the top.
- When scrolling reaches line 101 of the page being at the top, scrolling the panel to that position would move its bottom above the bottom of the window. So instead, it leaves its line 100 at top and stays
position:fixed
as you scroll further down.