Skip to content

Instantly share code, notes, and snippets.

@kudinovfedor
Created November 6, 2019 15:46
Show Gist options
  • Save kudinovfedor/c4ec1a50f3a248de84071b7a1f755d96 to your computer and use it in GitHub Desktop.
Save kudinovfedor/c4ec1a50f3a248de84071b7a1f755d96 to your computer and use it in GitHub Desktop.
Viewport Height 100 percent
/**
* 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