Anyone know how to prevent the zoom that happens when keyboard/spinner is displayed?
I do know that if you set meta tag viewport content to "user-scalable=no" then this zooming is not being done, but is there any way to prevent this anoying zoom without cutting all zooming functionality for users?
Thanks everybody!
After some testing I found out that depending on viewport size zoom is not made. I mean when having viewport:
<meta name="viewport" content="user-scalable=yes, width=280px" />
With no maximum-scale, nor initial-scale, then safari browser wont zoom in when keyboard/spinner is displayed.
I do not understand very well this behaviour, as I would say that logical width to avoid this zooming should be 320px...
I wont mark it as answer, just in case someone wants to add more light to this issue...
Prevent zooming all together by adding this meta tag to your head tag :
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0"/>
more solutions:
https://blog.osmosys.asia/2017/01/05/prevent-ios-from-zooming-in-on-input-fields/
Related
I am developing an iPhone App based on a UIWebView (hate it or love it). This page has a fixed width and pretty much static proportions. I have a few input textfields on this page, but whenever a user engages focus on one of these, the iPhone will zoom a bit in. Also, I can pinch-zoom on the web view.
How can I avoid that? I have Scaling: Scales Page To Fit and View Mode: Scale To Fill.
Thanks in advance.
You can try disabling it in a meta tag, like this:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
It is working for me
webViewHome.multipleTouchEnabled = NO;
And Change wkwebview property set "Aspect Fit " from "Scales to fill" in storyboard.
My site has a fixed layout with a size of 1090px.
When I use this meta tag:
<meta name="viewport" content="width=device-width, maximum-scale=1">
the page will load zoomed in. Not all the way though (roughly 300px in width are out of view).
Also, you can not zoom the page out far enough to see the whole thing.
Shouldn't the width=device-width solve that?
So I tried an initial-scale of 0.29, which worked fine for the iPhone. But when loading the site on an iPad, it would obviously be way too small.
How can I fix this?
UPDATE:
So I just figured, that the width seems to be defined by the height of my page.
Safari on the iPhone fits the height in the viewport and doesn't care about fitting the width, also won't let you zoom out to see the whole width. It seem like if the page would be higher, you could see more of the width.
The width is just fine in landscape.
If your design is not responsive, It is better to target particular device resolution like for 320 width I would go for <meta name="viewport" content="width=320">
I have also noticed that content set as device width tend to break on ios 4 safari. I am afraid it's not the problem of ios safari it's the non-responsive design that causing the problem.
Also if the design is not responsive, then using this combination is worst
user-scalable=no or maximum-scale=1 with initial-scale=1
playing with initial scale will not solve the problem for all the devices.
I am designing a mobile website and when I see my website in portrait view on iphone/ipod its layout, images everything is perfect but when I change to landscape view everything is showing a little bit zoomed-in. I have tried all the meta tag (viewport) attributes:
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=1" />
What am I missing? I want to continue to allow users to zoom, I just don't want the orientation change to zoom my content in.
The guys behind jQuery Mobile have a solution to this. It works by checking the accelerometer data and disabling zoom while the device is changing orientation.
I have built a website that I thought was free from css errors until I test this on the iPhone. I have a strange problem in that the repeating background images do not stretch fully across the page.
This is what it looks like on an iPhone and full website URL:
Example website
Try this: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
The problem is the same for if you reduce the width of your browser. The problem is the background IS stretching, but the website is only as wide as the stretched background image. The slidey bit below the logo has a fixed width though and is creating the illusion that the background isn't stretching far enough.
The above code should fix this issue by making sure that the website zooms to fit the width of the browser.
Turn off auto-scaling by setting a viewport meta tag to the head section of your HTML. This sets the width of your page to match the width of the display,
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
Sadly adding the viewport to set the zoom to 100% was not what I was looking for.
After debugging further I found that the problem was being caused by the large banner image at the top. This was a larger width than the rest of the website, by changing this to a centered background image and adding overflow hidden to the container fixed all issues.
I asked a question and received an answer regarding sizing images for mobile browsers.
The answer provided works for inline images. However, I need to use background images as part of a header, as well. They're set via css classes. On android, they scale correctly in both portrait and landscape, but on iPhone they automatically zoom in when turning from portrait to landscape. This is a problem. I have a viewport tag set like so:
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
Apparently when the iPhone (at least the newest versions) are turned to landscape mode, it rescales and zooms in really huge, rather than just repeating the background more times to account for the wider screen.
Here's what my code looks like:
<tr><td colspan="2" class="logoHeader"><img src="/images/mobile/logoCopy.png" /></td></tr>
where class logoHeader looks like this:
td.logoHeader {
background: url(/images/mobile/transparentLeavesRight.png) top right no-repeat,
url(/images/mobile/transparentLeavesGradient.png) top left repeat-x;
text-align:center;
}
Any ideas? I know that I can add the user-scalable property of the viewport meta, but we don't want to prevent users from manually zooming if necessary. We just want to prevent it from automatically zooming when the phone is turned into landscape mode.
FYI: I did search and found this and this, which are pretty much asking the same question. But they're both a number of months old, and neither has an actual answer to the problem, so I'm hoping that someone has come up with something in the interim.
to avoid rescaling when orientation changes try
<meta name='viewport' content='width=1024' />
and adjust width for your needs. If this won't work on android correctly, you can always send different viewport tag by PHP+user agent detection, or set it on device by javascript.
Change the viewport to:
<meta name="viewport" content="width=device-width, initial-scale="selfrender"/>