JSFiddle - React, Tailwind, and code Playground

by lindsay bradford

HTML

<div class="Center-Container">
   <div class="Center-Block Absolute-Center is-Variable">
<h4 class="Title">Absolute Center,<br> Variable Height.</h4>
<p>This box is absolutely centered vertically within its container, regardless of content height.</p>
   </div>
</div>

CSS

.Center-Container {
background: #2e5f3e;
color: #4fa46b;
width: 100%;
height: 400px;
margin: 20px auto 40px;
clear: both;
}

.Center-Container {
position: relative;
}

.Center-Block {
background: #4fa46b;
color: #FFF;
padding: 20px;
}

.Center-Block .Title {
padding: 0;
margin: 0 0 .5em;
line-height: 1em;
}

.Absolute-Center.is-Variable {
display: table;
height: auto;
}


.Absolute-Center {
height: 50%;
width: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}


p {
    font-size:10px;
    padding:10px;
    color:#fff;
}