Test y fallback con modernizr para comprobar el soporte de VH-VW
Created
October 9, 2015 10:30
-
-
Save BCasal/99e23c6b04ba1ac6e069 to your computer and use it in GitHub Desktop.
Test & FallBack VH
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
// 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