Responsive Media YouTube CSS

Published on Monday 1, December 2014

Make the Media: YouTube module responsive friendly with this tidbit of CSS. This snippet provides a responsive solution but doesn't force it to be full width (it will respect the width set on the elements.)

.media-youtube-video {
    float: none;
    clear: both;
    max-width: 100%;
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 0;
}
.media-youtube-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 100%;
    max-height: 100%;
}

 

#