Having an absolute positioned DIV with a defined height and width sometimes leads to it being cropped out when it doesn't fit the viewport's height. This can be frustrating, as shown in the images below:
I've attempted various methods such as using overflow: scroll on the overlay div, the div itself, and even the body, but none of them have provided a solution without resorting to JavaScript. Is there any way to address this issue purely through CSS?
HTML
<div id="overlay">
<div id="login">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
CSS
#overlay{
width: 100%;
height: 100%;
position: fixed;
background: rgba(0,0,0,.8);
z-index: 100;
}
#login{
width: 250px;
height: 320px;
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
margin: auto;
background: #fff;
}