Skip to main content
  • X Twitter
  • youtube
Home
Drupal 4U
Built for AI. Powered by Drupal.
  • Home
  • Showcases
  • Services
  • Blog
  • About
  • Contact

Breadcrumb

  1. Home
  2. HowTos
  3. How to make the embed Youtube player responsive using Drupal

How to make the embed Youtube player responsive using Drupal

HowTos
December 17, 2014
Profile picture for user drupal
By drupal
  • facebook-f
  • twitter
  • envelope
  • print
285

Many Drupal modules such as Media: YouTube or Video Embed Field offer a very easy way to integrate the embed Youtube player as field. In a time where responsive design has become a must, it is quite surprising that they all don't offer any responsiveness. Furthermore most of the free and paid themes who integrate Youtube/Vimeo apparently also don't consider this aspect. But with a small twist you can easily fix it yourself. With the following CSS and HTML code you can make your embed Youtube player responsive.

Important Note: If you use views with fields for the integration, you can just add the CSS code and then assign the class video-container to the Youtube field (Customize field HTML > Create a CSS class). If you want to add the class to fields of content types, you can for instance use the module Field Formatter Class.

For more information see: http://avexdesigns.com/responsive-youtube-embed/
For the customization of the Youtube player: https://developers.google.com/youtube/player_parameters
Alternatively you may consider: https://www.drupal.org/project/fitvids

CSS

  1. .video-container {
  2. position: relative;
  3. padding-bottom: 56.25%;
  4. padding-top: 30px; height: 0; overflow: hidden;
  5. }
  6.  
  7. .video-container iframe,
  8. .video-container object,
  9. .video-container embed {
  10. position: absolute;
  11. top: 0;
  12. left: 0;
  13. width: 100%;
  14. height: 100%;
  15. }

HTML

  1. div class="video-container">
  2. iframe src="http://www.youtube.com/embed/dFVxGRekRSg" frameborder="0" width="560" height="315">/iframe>
  3. /div>

Example

How to make the embed Youtube player responsive using Drupal
Optimisation

Read more articles

Newer
Drupal Performance Optimization: How to speed-up your Drupal website?
Older
Troubleshooting: Impossible to save settings for a new Multimedia asset field
  • Log in to post comments
Profile picture for user drupal
drupal
285
1
min read
A- A+
  • facebook-f
  • twitter
  • envelope
  • print

Contact Us

Get in touch for questions and our Drupal development, design and optimization services.

Contact Us

We aim to reply the latest within 48h.

Drupal 4U: Built for AI. Powered by Drupal.

We are a group of Drupal designers, developers and webmasters. We are Drupal experts! We provide comprehensive services that go beyond traditional web development, focusing on how AI understands, interprets, and cites your content. With our deep expertise in Drupal's architecture, we build the intelligent core of your digital presence, ensuring your brand remains authoritative and visible in a world where AI is the primary gatekeeper of information. Partner with us and let's future-proof your digital strategy together.

  • X Twitter
  • youtube

Drupal Services

  • Drupal Web Design
  • Drupal Development
  • Drupal SEO
  • Drupal GEO
  • Drupal Migration

Drupal 4U

  • Services
  • Showcases
  • Blog
  • About

Drupal Links

  • Official Drupal Website
  • Drupal Answers
  • Gaivas Themes Drupal 11
  • More Than Themes
  • Theme Forest
  • DXPR: Drupal for Marketers
2012 - 2025, Drupal 4U

Footer menu

  • Contact
Home
Drupal 4U
Built for AI. Powered by Drupal.
  • Home
  • Showcases
  • Services
  • Blog
  • About
  • Contact
Clear keys input element