Skip to main content

Post categories

  • Drupal Tips & Tricks
  • Drupal Howtos
  • Drupal Themes
  • X Twitter
  • youtube
Home
Drupal 4U
Drupal Development, Drupal Web Design, Drupal SEO
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • 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
281

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
281
1
min read
A- A+
  • facebook-f
  • twitter
  • envelope
  • print

Contact Drupal 4U

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

Contact Us

We aim to reply the latest within 48h.

About Drupal 4U

We are a group of Drupal designers, developers and webmasters and we launched this website to share our experience and knowledge with you. Drupal is a free software package that allows you to easily organize, manage and publish your content, with an endless variety of customization. Drupal is open source software maintained and developed by a very large community of developers and users.

  • X Twitter
  • youtube

Drupal Services

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

Drupal 4U

  • Services
  • Showcases
  • Themes
  • Blog
  • About

Drupal Links

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

Footer menu

  • Contact
Home
Drupal 4U
Drupal Development, Drupal Web Design, Drupal SEO
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • About
  • Contact
Clear keys input element