Ok, so I have a very simple stack:
---------
| A |
---------
| B |
---------
| C |
---------
Both A and C have known and fixed heights. Yet the window height (a mobile viewport) is unknown. I’m trying to get B as tall as possible. I’m going to use overflow-y: auto, so overflowing is not an issue. The actual issue is expanding it to an unknow (but calculable) value.
I have solved this by calculating $(window).height() - ($(A).height + $(C).height()), but there must be a better way (or a jQuery plugin).
Make sure that the container has a non-
staticpositioning, then makeBposition: absolute;and set bothtopandbottomto the heights of A and C, respectively.For example, if
Awere 20 pixels tall andC40, your CSS forBwould look something like this: