Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic resize of Vimeo Video (or Youtube)

I added to to the iframe a class with css

width:100%;
height:auto;

but does not work for the height.

Any ideas better than jquery dirty fix

$(window).resize(function(){
    var tempwidth=$(".vimeoiframe").width();
    var tempheight=tempwidth/1.25;
    $(".vimeoiframe").css("height",tempheight);
});

Since not all my videos have this aspect ratio.

like image 574
Daniel Avatar asked May 07 '12 18:05

Daniel


People also ask

Can you resize videos in Vimeo?

By simply going to the website and navigating to the “Resize” tab you can quickly upload and resize a video clip.

How do I embed a Vimeo video responsive?

In the share window that appears, click on "+Show options" in the top right corner of the lightbox, then select "Responsive.” The code in the embed section should then automatically adjust to include a new div wrapper and script tag. These elements allow the iframe to become responsive.


2 Answers

You should take a look at this jQuery plugin, seams that was wrote for you

FitVids.js

There is an entire article about it on CSS Tricks as well

Fluid Width YouTube Videos

And his .net magazine article

Create fluid width videos

like image 164
balexandre Avatar answered Oct 10 '22 21:10

balexandre


Or you could use percentage ratios, http://codepen.io/maxmckenzie/pen/hFzak the video dose not load in codepen for some reason.

like image 40
max Avatar answered Oct 10 '22 21:10

max