I have an element centered in the middle of a page. If the page shrinks to less than the height of the element, I need to still show the top of the element instead of being centered. I would like the element's container to be scrollable.
.card-display {
margin: auto;
top: 50%;
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
height: 400px;
background-color: grey;
border-radius: 10px;
}
<div class="card-display" >
<div>
always need top line visible (i.e., if there is enough container height to fit the grey element, it should be vertically centered, otherwise container have scrolling)
</div>
</div>