/* Parent element can be any width and height */
.parent{
    position: fixed;
    width: 100%; /* can be any width */
    height: 100%;
    left: 0;
    top: 0;
    display: none;
    text-align: center;
}

.parent:before{ /* pseudo element to force vertical centering of child element */
    content: '';
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

.parent:after{ /* pseudo element to create overlay */
    background: black;
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0.5;
    z-index: 10;
}

/* Centered child element can be any width and height */
.centeredchild{
    position: relative; /* position element to participate in z-indexing */
    z-index: 20; /* higher z-index than overlay */
    display: inline-block;
    vertical-align: middle;
    width: 80%; /* can be any width */
}

/* Close button */
.close {
    position: absolute;
    top: 10px;
    right: 20px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 30; /* higher z-index than video */
}

.close:hover,
.close:focus {
    color: #ccc;
    text-decoration: none;
    cursor: pointer;
}

/* Video container to maintain Youtube 16:9 aspect ratio */
.videowrapper{
    position: relative;
    padding-top: 25px;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
}

/* Make Youtube IFRAME responsive */
.videowrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}