Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  178] [ 2]  / answers: 1 / hits: 54929  / 11 Years ago, thu, august 22, 2013, 12:00:00

I have the max-height of an element as 65vh. I need to convert it to pixels in my JavaScript to see whether an image can fit there or if I need to shrink/crop it. (am doing win8 App development).



Will this work?



100 vh = screen.height therefore 65vh in pixels is screen.height *0.65


More From » css

 Answers
27

Not necessarily screen.height * 0.65, but viewport.height * 0.65. Even though a Windows 8 app will always have the same height, regardless of the snapped state, this is an important difference in browser-based applications.



In JavaScript:



document.documentElement.clientHeight * 0.65;


If you're using jQuery, you can do:



$(window).height() * 0.65;

[#76206] Wednesday, August 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dustin

Total Points: 599
Total Questions: 105
Total Answers: 106

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
dustin questions
;