Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  156] [ 7]  / answers: 1 / hits: 15779  / 9 Years ago, fri, march 27, 2015, 12:00:00

I have a problem with displaying my html site on different monitors/resolutions. I was trying to to solve this problem with the following script, but it isn't working. How could I improve this?





if (width <= 1280 && height <= 720) {
document.getElementById('html').style.zoom = '50%';

html {
zoom: 100%;
}




More From » html

 Answers
42

You could scale the content without javascript, just using a mediaquery and a CSS3 transformation applied to the html element



@media screen and (max-width: 1280px) and (max-height: 720px) {
html {
transform: scale(.5);
// or simply zoom: 50%
}
}


as a side note your code can't work because you're looking for an element with id=html, while you're trying to target the html element (that is document.documentElement or document.querySelector('html'))


[#67287] Wednesday, March 25, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
miles

Total Points: 256
Total Questions: 111
Total Answers: 104

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
;