The code:
<select>
<option value="1">Home</option>
<option value="2">About</option>
<option value="3">Services</option>
<option value="4">Contact</option>
</select>
When I touch select
, the iPhone zooms in that element (and does not zoom out after deselecting).
How can I prevent this? Or zoom back out? I can't use user-scalable=no
because I actually need that functionality. It's for iPhone, select menu.
We ran into this issue at my work and found a similar answer to @alex. We can manipulate the viewport tag if it is an iOS device:
This prevents zooming form controls on focus in iOS and still allows Android to work as normal.
Not working anymore on iOS10.0.1
font-size:16px
workshere is the jQuery Solution works well for me.
UPDATE: This method no longer works on iOS 10.
It depend from the Viewport, you can disable it in this way:
add
user-scalable=0
and it should work on your inputs as well.For iOS, you can avoid zooming of input elements by simply allocating a font size to them that's considered sufficient by the OS (>=16px), thus avoiding the need to zoom, e.g.:
It's a solution also utilized by various frameworks and allows you to avoid the use of a meta tag.
Setting the font size works perfectly for input elements, but not for select elements for me. For select tags, I need to actively disable viewport zoom when the user starts interacting with the select element, and then reenable it on finish.