Created
March 26, 2018 19:17
-
-
Save pyroflies/f9263123adf9071fcf99b855af0f22a0 to your computer and use it in GitHub Desktop.
Full Screen Video Resize Fill
This file contains hidden or 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
var video = $('#video'); | |
var resizeVideo = function() { | |
var w = $("body").prop("clientWidth"); | |
var h = window.innerHeight; | |
var ratio = 0.5625; // 720x1280 or 1080x1920 | |
if (h/w > ratio) { | |
var width = ((h/720) / (w/1280)) * 100; | |
video.css('width', width + '%'); | |
video.css('height', '100vh'); | |
} else { | |
var height = ((w/1280) / (h/720)) * 100; | |
video.css('width', '100%'); | |
video.css('height', height + 'vh'); | |
} | |
} | |
$(window).resize(function() { | |
resizeVideo(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment