If the focus is set to an item, Safari (and Chrome also) will zoom in to this item. After zooming not all of the page is visible any more. When for example the date item is selected after zooming the date picker icon shifts out of sight. So it is desirable to avoid the auto zooming.
After some googling it is clear that the autozoom is applied to items with a font size less than 16px.
The easiest solution to prevent this zooming is to size up the font size of all items to 16px. We can attain this by applying the following CSS:
input, select, textarea {
font-size: 16px!important;
}
Now all font size 16px is applied to all items. You can see the differences in the images below.
Left is the page with autozoom, right is the page with the fix applied.
As you can see after autozoom the page is partly invisible. The user needs to pinch to view the full page.
The !important postfix in the CSS is a bit blunt. It is used to avoid complex and extensive CSS specifications with references to Universal Theme classes.
Solution specific for iOS
Now putting this CSS on the page just like that it will affect the application for all platforms.A more elegant solution is to apply this CSS only on iOS. That can be done by creating a region on the global page 0 and creating a PL/SQL Dynamic Region that only writes the style specification for iOS:
- open Page 0
- right click on Content body and select Create Region
- select the new region
- Name: Prevent Autozoom
- Type: PL/SQL Dynamic Content
- Template: - Select -
- PL/SQL Code:
declare l_agent varchar2(1000); begin l_agent := lower(owa_util.get_cgi_env('user-agent')); if l_agent like '%iphone os%' then htp.p('<style>input,select,textarea {font-size:16px!important;}</style>'); end if; end;With this solution the CSS is only applied to iOS. The font sizes on other platforms are unaffected.
The user-agent CGI variable contains information about the browser and platform used. When the string iphone os is present in the lower case user-agent string the page is displayed on iOS.
Alternative solution
There is another smart, but rather complex solution:- setting the font size to 16px
- sizing the item relatively to the change in font size
- use CSS scaling to resize the items back to the original size
This solution is described in the blog No input zoom in Safari on iPhone, the pixel perfect way by Jeffry To.
No comments:
Post a Comment