I have a webapp with buttons on one side. When I click one of these buttons, *JavaScript magic*, a menu appears next to it. The script knows nothing about positioning or style, it just finds a target element then writes HTML inside.
In short, I have a menu positioned relatively to its parent (#pretty-target
in this example).
<div class="container">
<button class="my-pretty-button">@</button>
<div class="menu-target" id="pretty-target"></div>
</div>
The result looks like this:
Now, when I reduce the page height, I would like to limit the height of this menu, depending on its distance from the bottom of the page. A more-than-ideal result would look like this:
I know the very best practice would be to have a scrollable page body and don't bother about the height of such elements. However, my page body is a map, so any attempt to scroll it would just move the map.
I could certainly craft some alternative thing by using a scrollable overlay, or, even better, by using media queries to choose a better method for displaying these menus. But then, they wouldn't be displayed this way.
Briefly: I have a page-independent div, and I want it to be height-limited by the page height. How could this work (without using JS)?