Skip to content

Instantly share code, notes, and snippets.

@rcerrejon
Created July 26, 2016 15:04
Show Gist options
  • Save rcerrejon/022713eb61cd18fecb3310bab455fc84 to your computer and use it in GitHub Desktop.
Save rcerrejon/022713eb61cd18fecb3310bab455fc84 to your computer and use it in GitHub Desktop.
Responsive iFrame (video responsive)
if ($('.vimeo-iframe').length > 0) {
oWindowWidth = $(window).outerWidth();
oWindowHeight = $(window).outerHeight();
windowWidth = $(window).outerWidth() - 10;
windowHeight = $(window).outerHeight() - 128;
wCalc = ((windowWidth * 100)/1280);
hCalc = ((windowHeight * 100)/720);
rwCalc = 1280 * (hCalc/100);
rhCalc = 720 * (wCalc/100);
if (oWindowWidth < 1280) {
$('.vimeo-iframe').attr('width', windowWidth + 'px');
$('.vimeo-iframe').attr('height', rhCalc + 'px');
}
if (oWindowHeight < 720) {
$('.vimeo-iframe').attr('height', windowHeight + 'px');
$('.vimeo-iframe').attr('width', rwCalc + 'px');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment