Skip to main content
New Participant
December 24, 2014
Answered

Embed YouTube video is not responsive

  • December 24, 2014
  • 2 replies
  • 31765 views

Hello all!

I am trying to make my embed YouTube video responsive in my website. I am using Fluid Grid Layout html 5.

The css code I used:

.video-container {
position: relative;

padding-bottom: 56.25%; padding-top: 30px; height: 0;

overflow: hidden;

}

.video-container iframe,

.video-container object,
.video-container embed {

position: absolute;

top: 0px;

left: 0px;

width: 100%;

height: 100%;

}

Html code:

<div class="gridContainer clearfix">

<div class="video-container"><iframe src="http://www.youtube.com/embed/23T2VMtzVrE?rel=0" frameborder="0" allowfullscreen></iframe></div>


The video will only show if I make the class into an id

Example:

<div class="gridContainer clearfix">
<div id="video-container"><iframe src="http://www.youtube.com/embed/23T2VMtzVrE?rel=0" frameborder="0" allowfullscreen></iframe></div>

And if I add the width and the height the video will still not be responsive

Example:

<div class="gridContainer clearfix">
<div id="video-container"><iframe width="640" height="480" src="http://www.youtube.com/embed/23T2VMtzVrE?rel=0" frameborder="0" allowfullscreen></iframe>

</div>

Can someone please help? Thank you.

This topic has been closed for replies.
Correct answer Nancy OShea

OK.  Try removing the styles in Red.

.video-container {

    position: relative;

    padding-bottom: 56.25%;

    padding-top: 30px;

    height: 0;

    overflow: hidden;

}

Nancy O.

2 replies

sanderrzkelly
New Participant
December 30, 2024

To make your Embed YouTube video responsive, you can use a plugin called "YT Portrait Video Embed ". This plugin is free and Easily available on wordpress. 

Simply use shortcode and video ID. And its done. Hope this will help! 

Troubleshoot YouTube embed blank space WordPress
Nancy OShea
Community Expert
December 30, 2024

[10-year-old topic locked by moderator.]

 

Nancy O'Shea— Product User, Community Expert & Moderator
Nancy OShea
Community Expert
December 24, 2014

This works for me.  Live example:

Alt-Web :: Fluid Grid Test

Relevant CSS:

.video-container {

  position: relative;
  padding-bottom: 56.25%;
  padding-top: 30px; height: 0; overflow: hidden;
}

.video-container iframe,
.video-container object,
.video-container embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

================

HTML:

<div class="video-container">

<!--YOUTUBE CODE-->

<iframe width="560" height="315" src="http://www.youtube.com/embed/your_video_ID" frameborder="0" allowfullscreen></iframe>

<!--end video-container--></div>



Nancy O.


Nancy O'Shea— Product User, Community Expert & Moderator
99ctcAuthor
New Participant
December 24, 2014

Thank you for the reply. But this code still does not work for me. A link

to my page:

http://dwdemo.co.nf

Again, thank you.

Nancy OShea
Nancy OSheaCorrect answer
Community Expert
December 24, 2014

OK.  Try removing the styles in Red.

.video-container {

    position: relative;

    padding-bottom: 56.25%;

    padding-top: 30px;

    height: 0;

    overflow: hidden;

}

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator