Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
make vimeo embeds responsive
// Responsive Vimeo Embed: http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php
var $allVideos = $("iframe[src^='//player.vimeo.com']");
$allVideos.each(function() {
$(this)
.data('aspectRatio', this.height / this.width)
.removeAttr('height')
.removeAttr('width');
});
$(window).resize(function() {
$allVideos.each(function() {
var $el = $(this);
$el.width( $(this).parent().width() ).height( $(this).parent().width() * $el.data('aspectRatio'));
});
}).resize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.