I am looking for a way to create dynamic max-height without it being fixed. Let's imagine we have two divs on a page - if div#1 is hidden, I want the max-height of div#2 to automatically increase to occupy the maximum area before scrolling becomes necessary. The scroll should only come into play when div#2 goes out of the viewport.
Check out this sample jsbin: http://jsbin.com/voworuveqe/edit?html,css,js,output
Edit
I would appreciate CSS solutions only, no JavaScript. Thank you!