 [ ← blog / drupal ](/) Dec 01, 2014  ·  \#drupal  ·  1 min read 

# Responsive Media YouTube CSS



Make the [Media: YouTube](https://www.drupal.org/project/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.)

```css
.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%;
}
```

 

  ![](/themes/custom/mglaman/images/headshot.webp)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.

 [Subscribe via RSS →](/rss.xml) [About me →](/about-me) 

 



 

  [← Older

Programmatically change the "Add to Cart" line item type

 ](/blog/programmatically-change-add-cart-line-item-type) [Newer →

Drupal Issue Tracker, Chrome App

 ](/blog/drupal-issue-tracker-chrome-app)