Reputation: 382
I'm working in a legacy codebase where the existing web pages are not built in a mobile-responsive fashion. I am working on slowly migrating these web pages to be responsive, and I have come across a case where I need to switch to a responsive view some time after the page has already loaded. To accomplish this, I am using JavaScript to add the viewport meta tag.
I am encountering some unusual behavior where the initial-scale
property is behaving as if it were slightly zoomed in. i.e., initial-scale=1
is behaving more like intial-scale=1.2
. I have reproduced this behavior on https://google.com, you can do so with the following steps:
const viewport = document.createElement("meta");
viewport.name = "viewport";
viewport.content = "initial-scale=1.0";
document.head.appendChild(viewport);
I've already tried adding width=device-width
, but that didn't change the behavior.
Any ideas on how to prevent this?
Upvotes: 0
Views: 29