<div class="parent">
<div class="child">
'm a block-level element with an unknown height, centered vertically within my parent.
</div>
</div>
.parent {
background: black;
height: 300px;
padding: 0 30px;
position: relative;
}
.child {
background: white;
width: 200px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.