JSFiddle - React, Tailwind, and code Playground

by Aleksey Karagodnikov

HTML

<div class="fixed-overlay fixed-overlay__modal">
    <div class="modal">
        <div class="modal_container"> 
            Hello, Habr!
        </div>
    </div>
</div>

CSS

* {
    box-sizing: border-box;
}

.fixed-overlay {
    position: fixed;
    overflow: auto;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.fixed-overlay__modal {
    text-align: center;
    white-space: nowrap;
}

.fixed-overlay__modal::after {
    display: inline-block;
    vertical-align: middle;
    width: 0;
    height: 100%;
    content: '';
}

.modal {
    display: inline-block;
    vertical-align: middle;
}

.modal_container {
    margin: 50px;
    padding: 20px;
    text-align: left;
    white-space: normal;
    background-color: #fff;    
    color: #000;
}