从纵向旋转到横向时,iPad 布局会放大
我在 "viewport"
元标记中添加了 "width=device-width,initial-scale=1.0"
,在 iPad 上,页面在横向模式下加载良好,它很好地切换到纵向,当我将其旋转回横向时,它会放大页面,我必须将其缩放回 1 比例。
我可以通过添加“maximum-scale=1.0, user-scalable=no”来解决这个问题,但我想知道是否有一种方法可以解决这个问题,而不剥夺用户的能力放大页面。
如果您有任何建议,我很想听听,
谢谢!
I have a added to the "viewport"
meta tag "width=device-width,initial-scale=1.0"
and on an iPad the page loads up fine in landscape mode, the it switches nicely to portrait and when I rotate it back to landscape it scales the page up and I have to pinch zoom it back to a 1 scale.
I can fix this by adding the "maximum-scale=1.0, user-scalable=no"
, but I was wondering if there is a way I could fix this without taking away from the user the ability to zoom in the page.
If you have any suggestions I would love to hear them,
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
第一个修复对我有用,并进行了以下更改。
将初始比例更改为 0.8,最小比例更改为 0.25,最大比例更改为 1.6。
使用“元”标签
The first fix worked for me with the following changes.
Change initial scale to .8, minimum to .25 and maximum to 1.6.
Use the "meta" tag
当你说它放大页面时,是所有元素还是只是文本字体大小?...为了固定字体大小,你可以使用:
When you say it scales the page up, is that all elements, or just the text font size?... For fixing the font size you can use:
到元:
到全局脚本:
to meta:
to global script:
jQuery mobile 使用的修复位于此处
https://github.com/scottjehl/iOS-Orientationchange-Fix
缩小版
完整源代码
The fix used by jQuery mobile is here
https://github.com/scottjehl/iOS-Orientationchange-Fix
Minified
Full source
这似乎是 iOS 4 中的一个错误,可以使用以下 Javascript 代码片段进行修复,但是它会禁用用户进行捏合缩放的能力:
https://gist.github.com/901295/229d163414e22ebb14a6a6ba0b9777118f02e52d
This seems to be a bug in iOS 4 which can be remedied with the following Javascript snippet, however it disables the user's ability to do pinch-to-zoom:
https://gist.github.com/901295/229d163414e22ebb14a6a6ba0b9777118f02e52d
这个有效!
This one works !
为了使脚本正常工作并绕过第二个手势细微调整(例如方向更改事件),请将最大值设置为 1.00099 而不是 1.0
In order for the script to work and bypass the 2nd gesture minor tweaking like in orienatation change event set the max to 1.00099 instead of just 1.0
我想出了一个不同的解决方案,将旋转时的缩放保持在 1,但允许用户捏合缩放。基本上,当用户缩放时,JavaScript 会更改视口缩放级别(并且本机浏览器缩放功能被禁用)。
在这里查看:https://stackoverflow.com/a/11878932/436776
I came up with a different solution to keep the zoom at 1 on rotation, but allow the user to pinch-to-zoom. Basically when the user zooms, javascript changes the viewport zoom level (and the native browser zoom functionality is disabled).
See it here: https://stackoverflow.com/a/11878932/436776
Scott Jehl 提出了一个出色的解决方案,它使用加速度计来预测方向变化。该解决方案响应速度非常快,并且不会干扰缩放手势。
https://github.com/scottjehl/iOS-Orientationchange-Fix
缩小源:
Scott Jehl came up with a fantastic solution that uses the accelerometer to anticipate orientation changes. This solution is very responsive and does not interfere with zoom gestures.
https://github.com/scottjehl/iOS-Orientationchange-Fix
Minified source:
希望这会有所帮助...
Hopefully, this will help ...
------ 更新 ------
在 iOS7 中这不再是问题。 Scott Jehl 在 github scottjehl/iOS-Orientationchange-Fix 上提供了更好的修复,适用于 iOS6。
------ 原始答案 ------
Jeremy Keith (@adactio) 在他的博客上对此有一个很好的解决方案< a href="http://adactio.com/journal/4470/">方向和比例
保持标记可扩展
然后使用 javascript 禁用可扩展性,直到使用以下脚本手势启动:
------ Update ------
This is not an issue anymore in iOS7. And there is better fix by Scott Jehl on github scottjehl/iOS-Orientationchange-Fix that works for iOS6.
------ Original answer ------
Jeremy Keith (@adactio) has a good solution for this on his blog Orientation and scale
Keep the Markup scalable
Then disable scalability with javascript until gesturestart with this script: