Shrink to Viewport The script calculates maximum of available height for the element to fit the viewport and set it as max-height style. Usage new ShrinkToViewport(document.getElementById('aside'), { offset: 20 });