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.

JavaScript

1 1
PLUS
1 1
Courses Plus Student 5,057 Points

What's the best solution for fluid mobile videos?

I would love to include some fluid videos (that will work on mobile too) on a responsive design project.

I have tried and actually managed to work with the design of the <video> element. While it looked very nice functionality was really bad on mobile.

I have used an Amazon S3 video that was 3.43 MB, still it was rendering forever on 152mbps WIFI. There is no way anyone would have waited long enough to watch that video.

So I've came across Todd Motto's FluidVids, which looks good but I couldn't get it working.

Here is what I would like to achieve:

1, Look great on any device 2, Disable full screen, so the call to action button is visible all the time 3, Excellent loading time (Youtube?) 4, And obviously a fluid experience

Any advice or resource would be appreciated.

:)

6 Answers

dan lematy
dan lematy
4,157 Points

Why dont you just upload the video to youtube and then just use the iframe?

dan lematy
dan lematy
4,157 Points

youtube videos are responsive, just make the iframe 100%, like so

iframe { width:100%; }

1 1
PLUS
1 1
Courses Plus Student 5,057 Points

That's not really ideal because I get a vertical scrollbar, I lose the margin of the video div, the video doesn't keep it's ratio etc.

I'm sure it can be very easily done, I just need pointing out how. ☺

Boy Buijsman
Boy Buijsman
13,773 Points

There is a great article about fluid iframes on css-tricks: https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php

That one helpt me out when i needed to make one of my customers landingpage mobile friendly.

In addition to the CSS methods outlined on the CSS Tricks article fitvids.js is another popular option: http://fitvidsjs.com/

1 1
PLUS
1 1
Courses Plus Student 5,057 Points

Guys, thanks a lot for your input! I have looked into 'fitvidsjs' as advised, still I've ended up using something incredibly simple.

This is what I used and so far so good. :)

xxxx CSS xxxx

/* Flexible iFrame */

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

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

xxxxx HTML xxxxx

<!-- FitMyVideo --> <div class="Flexible-container"> <iframe src="http://player.vimeo.com/video/30421472?title=0&amp;byline=0&amp;portrait=0" width="546" height="307" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe> </div>