Skip to content

Instantly share code, notes, and snippets.

@chriscoyier
Created November 7, 2011 23:09
Show Gist options
  • Save chriscoyier/1346492 to your computer and use it in GitHub Desktop.
Save chriscoyier/1346492 to your computer and use it in GitHub Desktop.
$allVideos.each(function(){
var $this = $(this);
if (this.tagName == 'embed' && $this.parent('object').length) { return; }
var height = this.tagName == 'OBJECT' ? $this.attr('height') : $this.height(),
aspectRatio = height / $this.width();
$this.wrap('<div class="fluid-width-video-wrapper" />').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
$this.removeAttr('height').removeAttr('width');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment