Skip to content

Instantly share code, notes, and snippets.



Created Feb 14, 2016
What would you like to do?
Fix mobile layout thrashing from using VH's
var els = document.querySelectorAll('.vh-fix')
if (!els.length) return
for (var i = 0; i < els.length; i++) {
var el = els[i]
if (el.nodeName === 'IMG') {
el.onload = function() { = this.clientHeight + 'px'
} else { = el.clientHeight + 'px'

This comment has been minimized.

Copy link

@SeasonLeee SeasonLeee commented Jan 11, 2020

Hey, Adam, I found your command in Jen's tweet about 100vh issue.

Your solution is quite creative and impressive👍, but I wonder if this is a trade off with performance.🤔

Anyway, our team actually encountered 100vh issue not long ago, and we use the trick from this post to solve the problem.

Also a pretty neat trick!😆 the-trick-to-viewport-units-on-mobile


This comment has been minimized.

Copy link
Owner Author

@argyleink argyleink commented Jan 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.