Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force webpage to zoom to 100% on load

I am trying to set the zoom of a website to 100%. I understand that firefox doesn't support this but I am trying to get it to work in chrome.

I've set the zoom:

body {
  padding-top: 0px;
  padding-bottom: 20px;
  zoom: 100%;
}

And chrome appears to be seeing the css take effect:

enter image description here

But when I increase the zoom and refresh it does not get set back to 100%:

enter image description here

What am I doing wrong and how do I fix it? CSS/HTML/jQuery answers are all fine.

Edit: it looks like the best approach so far is to simuate a ctrl+0 keypress on load. I have figured out how to generate it but how do you trigger it without any user input?

var press = jQuery.Event("keypress");
press.ctrlKey = true;
press.which = 48;
// trigger press
like image 732
David Tunnell Avatar asked Dec 22 '15 16:12

David Tunnell


2 Answers

You, the author of the webpage, have no power (or should have no power) over the user's browser configuration. The browser's zoom feature is an accessibility feature; many users rely on it to make text readable. As the developer/designer, do your best to accommodate a 125% scale.

like image 60
Sampson Avatar answered Nov 07 '22 21:11

Sampson


Firefox does not support the zoom property, as it is (and has always been) non-standard. It only served to scale the content of a webpage, and isn't meant to control the actual browser's settings.

See https://css-tricks.com/almanac/properties/z/zoom/

like image 45
gkubed Avatar answered Nov 07 '22 20:11

gkubed