I need to align a (nested) element to the vertical center of its container element, but when the nested element becomes taller than the container, the container needs to scroll starting from the top of the nested content (without it extending up past the top).
I was looking for a quick solution to this, but I'm encountering a lot of noise in my search results, no matter where I look.
Ideally the solution would use Flexbox, but any and all solutions are welcome, as long as they work in ALL of the target browsers.
This needs to work in IE 11, Edge, and current versions of Firefox, Chrome, and Safari.
Please, before you mark this as a duplicate, ensure that the similar question has a clear solution for the same target browsers. Once I read comments on some of the solutions I've seen, I see they don't fit my use case.
Here's one thing I have tried, but the nested content stays centered, and extends past the upper and lower bounds of the container, instead of scrolling, when too tall:
<div class="float-container">
<div class="float-content">
<!-- Some content that changes height -->
</div>
</div>
.float-container {
margin-top: 50px;
height: calc(100vh - 100px);
display: flex;
align-items: center;
justify-content: center;
overflow-y: scroll;
}