Created
November 6, 2019 15:46
-
-
Save kudinovfedor/c4ec1a50f3a248de84071b7a1f755d96 to your computer and use it in GitHub Desktop.
Viewport Height 100 percent
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
/** | |
* Viewport Height 100 percent | |
* | |
* @param {string} element | |
* @returns {void} | |
*/ | |
const vh100 = (element) => { | |
const w = $(window); | |
const el = $(element); | |
if (el.outerHeight() > w.height()) { | |
el.css('height', w.height()); | |
} | |
w.on('resize', function () { | |
if (el.outerHeight() > $(this).height()) { | |
el.css('height', $(this).height()); | |
} | |
}); | |
}; | |
export default vh100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment