Created
July 3, 2012 16:52
-
-
Save pygeek/3040973 to your computer and use it in GitHub Desktop.
Maintains aspect ratio of widescreen video. change 'video' to be the tag, class, id, or combination of the three for element.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var el = $('video'), | |
maintain_aspect = function(){ | |
el.each(function(){ | |
var $width = $(this).innerWidth(), | |
$new_height = $width * .562; | |
$(this).css({'height' : $new_height}) | |
}) | |
}; | |
$(window).resize(function(){ | |
maintain_aspect() | |
}) | |
// on page load | |
maintain_aspect() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment