Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

mrx3
mrx3
8,742 Points

Can someone help me find a good site that explains how to make a YouTube video resize with the browser window.

I need some help finding a good example of how to make a YouTube video that's embedded resize with he browser window. Thanks in advance for any help.

5 Answers

mrx3
mrx3
8,742 Points

Thanks for the comments guys. Here's what if have, and Joshua it almost looks like yours. Let me know what you think. HTML below:

<div class="video-wrapper">
   <iframe width="560" height="316"
      src="http://www.youtube.com/embed/7pQQHnqBa2E">
   </iframe>
</div>
Kevin Naegele
Kevin Naegele
10,868 Points

Have you tried changing the px's into em's?

Joshua Briley
PLUS
Joshua Briley
Courses Plus Student 24,645 Points

Awesome! I'd love to see it when you're done. Please be sure to share it with us!

mrx3
mrx3
8,742 Points

Dude I would love to. I've put it one my Xampp Apache server to test it out, and it looks good in all three browsers. I don't have a web hosting company yet. Also, I've used three pictures that relate to the movie for each movie page, and I'm sure there's copyright issues. I've even went as far as to make sure each picture resizes with the browser window for mobile phones.

mrx3
mrx3
8,742 Points

And here is my css:

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  padding-top: 25px;
  height: 0;
}

.video-wrapper iframe{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
mrx3
mrx3
8,742 Points

Thanks Joshua much appreciated. I'm making a practice site called my favorite movies. Scarface, Goodfellas, Casino, The Empire Strikes Back, and Alien. I'm watching Scarface now, I'm at the part, "Maybe you can handle yourself one of those one way tickets to the resurrection." :D