Automatically resizing page height

I am trying to create a website on a page that shows different content based on the buttons you press, using multi-state boxes. When you press button 1, contents in state 1 appears. However, state 1 has more content than the other boxes, so there is more room left over when you click state 2 or state 3.

My question is, is there a way to automatically resize the page height so that when there is more white space, the page knows to move up and cover that space?