Skip to main content
← blog / drupal
Dec 01, 2014  ·  #drupal  ·  1 min read

Responsive Media YouTube CSS

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%;
}

 

Thanks for reading

I write about Drupal, PHP, and the quiet infrastructure behind large sites — caching, config, and testing. New posts land every week or two.