Skip to content

Instantly share code, notes, and snippets.

@fregante
Created November 22, 2014 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fregante/9cc4eeca13c68e16c1f6 to your computer and use it in GitHub Desktop.
Save fregante/9cc4eeca13c68e16c1f6 to your computer and use it in GitHub Desktop.
Fix Android variable VH units (when the browser's bar disappears vh change)
$(function () {
var $els;
var updateHeight = function () {
$els.css('height', ''); // reset previously-set height
$els.height($els.height());// set the current height in px
};
if (/android/i.test(navigator.userAgent)) {
$els = $('ELEMENTS-WITH-VH-UNITS');
updateHeight();//set instantly
$(window).on('orientationchange.vh-height-set', updateHeight);
}
});
@junorouse
Copy link

It doesn't work..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment