Skip to main content

Responsive Media YouTube CSS

Published on

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

 

I'm available for one-on-one consulting calls – click here to book a meeting with me 🗓️

#