<div class="flex-container"> <div class="greenbox">Some arbitrary content<br> that will set the dimensions of the div</div> </div>
.flex-container{ width: 100%; height: 100vh; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; } .greenbox { background: limegreen; text-align: center; padding: 2em; }