<main>
<div>
I'm a block-level element of an unknown height and width, centered vertically within my parent.
</div>
</main>
body {
background: #f06d06;
font-size: 80%;
padding: 20px;
}
main {
position: relative;
background: white;
height: 200px;
width: 60%;
margin: 0 auto;
padding: 20px;
resize: both;
overflow: auto;
}
main div {
background: black;
color: white;
width: 50%;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
padding: 20px;
resize: both;
overflow: auto;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.