问题
I've built a responsive site using Twitter Bootstrap here: http://zarin.me/cce/
The responsive design works great on iPad and iPhone, however when I flip the device from portrait to landscape, the site is zoomed in instead of adapting to the screen (pinching the screen works).
What am I missing? Is this a viewport issue? Here's the only viewport code I have in my :
<meta content="width=device-width, initial-scale=1.0" name="viewport">
Thanks in advance!
回答1:
You also want to add the maximum scale
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
UPDATED I agree with some of the comments, the declaration should not limit the scaling by the user as this is bad practice. The below is a better approach and I believe that the zooming bug has long since been fixed by Apple.
<meta name="viewport" content="width=device-width, initial-scale=1">
回答2:
While setting the maximum scale to "1" does work, it restricts your users from zooming in on anything within your site. Not ideal for user experience. Try this Javascript instead, iOS-Orientation Change Fix
回答3:
Set initial-scale=1.0
in the meta:
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
Then set -webkit-text-size-adjust:100%;
in the CSS:
body {
-webkit-text-size-adjust: 100%;
}
This approach doesn't stop a user from zooming in on your website but will ensure that the text doesn't get size adjusted automatically by the browser.
回答4:
I've seen this happening when one of the containers on the page spills past 100%. The page displays ok in the initial orientation, but when the orientation is changed the extra width somehow becomes in force, causing the page to scale in, and usually leaves a margin on the right or left. Worth checking all your media queries to make sure there is not some trailing padding or margin.
回答5:
The following works for me and allows users to zoom in
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
回答6:
Had exactly this issue on Ipad 3 and IOS 7.1.2
Using maximum-scale=1 fixed it and allows zoom
The js solution did not work
回答7:
If you are facing issue mainly in iPhone-X try <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" />
That's work for me.
来源:https://stackoverflow.com/questions/11165460/responsive-site-is-zoomed-in-when-flipping-between-portrait-and-landscape-on-ipa