Skip to content

Instantly share code, notes, and snippets.

@BCasal
Created October 9, 2015 10:30
Show Gist options
  • Save BCasal/99e23c6b04ba1ac6e069 to your computer and use it in GitHub Desktop.
Save BCasal/99e23c6b04ba1ac6e069 to your computer and use it in GitHub Desktop.
Test & FallBack VH
// Comprueba si el navegador soporta VH
// Si no lo soporta, aplica la mitad de la altura del navegador
// Incluso cuando cambia de tamaño
// Y avisa con un alert de que no lo soporta
//En caso contrario, solo avisa de que si lo soporta
if (!Modernizr.cssvhunit) {
(window.onresize=function() {
var height = window.screen.height,
flex_item = document.getElementsByClassName('flex-item');
for (var i=0; i < flex_item.length; i++) {
flex_item[i].setAttribute('style' , 'min-height:' + height / 2 + 'px;');
};
alert('Este navegador «NO» soporta VH-VW');
}).call(this);
} else {
alert('Este navegador «SI» soporta VH-VW');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment