Jquery Mobile phonegap vertical content limited to viewport on IOS - ios

I have a fairly strange issue that I'm experiencing with jquery mobile / phonegap and IOS.
I've created a web app with html / css and so far it works exactly as expected on android, (The content scrolls vertically in the viewport) however on ios (my test platform is an iphone 4s), the page is limited vertically to the viewport. It scrolls just fine, but all content that sits below the viewport vertically get's cut off, IE the only content that will display is what I see in the upper half of the page, nothing below the viewport will display.
an excerpt from my css file:
html, body {
min-height:100%;
overflow-x:hidden;
background-attachment:fixed;
}
body {
-webkit-touch-callout: none;
-webkit-text-size-adjust: none;
-webkit-user-select: none;
-webkit-font-smoothing: antialiased;
-webkit-backface-visibility: hidden;
-webkit-overflow-scrolling: touch;
}
and my html page, in the head section:
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1 minimum-scale=1; user-scalable=no" />
Here's a couple screenshots of the problem in action:
As you can see from the screen shots, the gradient "should" fill the whole page (ie, expand with content), and it doesn't as there seems to be a hard cutoff at the viewport edge, so any more than a single page of content is not getting displayed. While it's not visible in these screenshots the vertical scrollbars are appearing as they should and the scrolling works fine, just no content is displayed "below the fold".
I am not using iScroll or any other scrolling scripts, just fyi.
I'm not sure if this is some sort of height issue, as I have a min-height:100%; set on the html and body of the page, or if it's some sort of width-device-width issue in the meta tag? I also do not believe I have any overflow-y:hidden set, as that would have limited the content on other platforms, and they work perfectly.
I feel like I must be missing something really basic, as I'm sure it's got to be some sort of css setting somewhere that's limiting the content to the viewport only, and an exhaustive google search could find no similar issues.

Check if your apps default orientation is set to portrait instead of landscape, or if it even supports the portrait orientation. It almost looks like its displaying the app as if its in landscape mode while its clearly in portrait. You can find the available orientation in the Target>General tab, or in the info.plist.

So I've fixed it, and the weird thing is, I'm not exactly sure what I did to fix the issue.
I moved the .ui-page selector from the jquery-mobile file to my own css file, removed the min-height from the html selector and killed the overflow-x from the html, body selectors and boom, it now appears to be working as intended. Wacky... but hey, a win is a win. :)

Related

Why font-size in iPhone mail so tiny? Had to scale up to 26px

I'm working on a responsive email template for my employer. For the desktop size, I was able to leave the default font size at 16px and just use rem to adjust sizes as necessary. It looks fine on the desktop, in Gmail, and is fully responsive. However, when viewed in Mail on iPhone, the font is SO SMALL. I had to add a media query that increases the base font size to 26px to get reasonable font sizes in the email. I've tried doing some research, but it doesn't seem as if other people have had to do the same. There is very little CSS in the code, but here is what I have:
body, table, td, a, p, span {-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%;}
#media screen and (max-width: 600px) {
html, td {
font-size: 26px !important;
line-height: 1.3;
}
}
I also have
<meta name="viewport" content="width=device-width, initial-scale=1">
There is some other CSS having to do with resizing images, with margins, etc. but that is the only CSS dealing with font-sizes (all the rem info is inline so it isn't stripped out by Bronto/Gmail). If I resize it in the browser to a mobile size, the text looks massive, but when viewed on my iPhone, it looks great. I'm concerned that this may be an iPhone quirk though and that it will look massive on other types of devices. Does anyone have any insight?
Here is some code from the templates I use (where I don't see this issue):
Try making your <meta> tags look more like this:
<meta name="x-apple-disable-message-reformatting">
<meta name="viewport" content="width=device-width">
The first tag disables auto-scale in iOS 10 Mail, which could be affecting your text size. The second tag sets the viewport; forcing initial-scale shouldn't be necessary and could be throwing off your design.
Also try moving the inline body styles from the <body> tag to inside a universal selector in <style>, like so:
<style>
/* What it does: Stops email clients resizing small text. */
* {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
</style>
<body width="100%" bgcolor="#ffffff" style="margin: 0; mso-line-height-rule: exactly;">
Have you heard of the viewport meta tag? You should consider adding this tag to the meta on your site. Just be cautious though as it could manipulate other HTML elements you have already configured.
<meta name="viewport" content="width=device-width, initial-scale=1">
Here is a link to a page explaining what it does in further detail.
https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag
Okay, finally figured it out. Luckily I had been going through and making all our email templates responsive, and one of them didn't have a hero image. Guess what? The font size looked massive on mobile for the imageless-template! So after some experimentation, I found that
img {
width: 100% !important;
}
completely resolved the issue, so that now the actual font-size matches what is set in the CSS. Despite all the width:100% styles set on the image itself and on its parent containers, somehow the image must have been too large and triggered a resize of all content, I guess? If anyone has an explanation I'd love to hear it.
FWIW, I think you are complicating your life trying to use the text-size-adjust property.
According to the browser compatibility chart on this MDN document, there is poor browser support and it's buggy.
Secondly, the way I read this W3C doc I don't think you are using it for its intended purpose. W3C states that:
This module contains features of CSS relating to one possible
mechanism for adapting pages designed for desktop computer displays
for display on smaller screens such as those of mobile phones...
Its purpose is to provide a solution for pages which were designed for desktop display only.
As you know, older web pages which don't use the viewport meta tag will be scaled down to fit the viewport of a mobile device. The problem with this is that text often becomes too small to read and this text-size-adjust property proposes to remedy this by enlarging text on mobile devices.
I think if you continue to use the viewport meta tag, make your template responsive, and size elements so that they display well in all devices you would get good results if you don't use text-size-adjust, i.e. some like the following:
body, table, td, a, p, span {font-size:16px;}
Good sources of info about text-size-adjust:
https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust?v=control
https://drafts.csswg.org/css-size-adjust/#text-size-adjust
https://caniuse.com/#search=font-size-adjust

Responsive website works fine on Firefox responsive mode, but not in Chrome or Device

I built a website for myself which I believe is responsive as per my testing with Firefox's responsive mode. I tested all the pages with the iPhone resolution (375*667) both landscape and portrait mode and it worked great.
However when I try to open the same site in Chrome, it does not display properly. It also shows the same effect when viewed from an iPhone.
This is my site - http://v1chu.github.io/
The background images in used in section 2 and 3 are missing whereas it is working fine with Firefox (also in responsive mode). I can't see the background in my device as well.
Also the site content looks very small when viewed in Chrome and device. But it looks just fine when viewed in Firefox.
Please tell me if the way I have built the site is right or not ? Or if something that I have missed which messes up the site on Chrome and devices.
You're heading in the right direction.
Problem #1, Background Images
Your background images don't appear because you are using the background-attachment property with the value fixed. It sets the background in relation to the viewport (browser window). You're basically pinning the background image to the top of the page and by the time you get to your 2nd and 3rd sections you've scrolled past the background image.
You have set background-attachment via the shorthand background property. Remove fixed from the background property.
background: url( '../img/aboutme.jpg' ) no-repeat center;
Problem #2, Text size
You need to use a responsive meta tag. Here's one that I use:
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
The problem seems to be here:
.s2 {
background: url(../img/aboutme.jpg) no-repeat center fixed;
}
I removed the fixed and the background displayed in chrome
s2 {
background: url(../img/aboutme.jpg) no-repeat center;
}

An iframe is wider than it should on iPhone

I have an iframe that I am embedding into a responsive WordPress theme. It looks good on some mobile devices, but on iPhone, the iframe is a bit wider than it should and it gets out of the container so users can't see the right part of the iframe (which is probably around 20-30px). This happens on portrait mode - if the orientation is set on landscape, it looks ok.
The content of the iframe is responsive as well, I'm using bootstrap. Also it looks ok on resized desktop browsers and on Android mobile devices. So the problem is only with the portrait iPhone orientation.
I am using this in the head of my iframe:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Any ideas?
Thank you!
Mobile Safari seems to not recognize width attributes on iframe, but recognizes min-width.
iframe{
width: 1px;
min-width: 100%;
}
The problem is that mobile Safari ignores the iframe width attribute. I created a new question here and answered it myself with the solution: How to set the width of an iframe in iOS6?
For the meta tag try starting with:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
If that doesn't solve it, look for what's causing the frame to be too wide, e.g. iframe dimension settings, width, padding or margins of elements inside the iframe, as well as margins or padding on the WordPress div that contains the iframe.
Remember that the iframe content is a completely seperate document so you need to double check details in both the parent WordPress page and the iframe page.
Good luck!
edit
You could also check it's not a default browser setting by using a reset in your WordPress CSS, e.g.
iframe{
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
}

Page rendering more narrow and not centered on iPad

Here is a page I am working on for a class. Don't worry that it's all divs - the exercise allows that as it was to experiment with web fonts.
My problem is that the page renders fine in IE, Firefox, Safari, but on the iPad it doesn't center and the scale is off. If you look at the top left header "Top of the Napkin", it actually breaks into 2 lines on the iPad. There is no left margin yet quite a bit of right margin.
thanks for any help -
The above answer did not work for me on the iPad. Here is what did work.
In the body tag I added the minimum width of what I would want in a browser.
body { min-width:1080px; }
This worked without adding
<meta name="viewport" width=device-width />
but I left it in the header for good measure.
I checked the page on my iPad (latest IOS v5.1) and I can see the text "Top of the Napkin" on one line, though you are right about the entire page not getting center aligned..
For that, I would suggest you to do 2 things;
A. Set the viewport width as below (add this line inside your head element);
<meta name="viewport" width=device-width />
The above line would set your viewport width to device-width (i.e. 768px on the iPad). You can even hard code the value as
<meta name="viewport" width=900 />
Though this is not the best approach.
B. The other thing you can try is giving the following style to your body element
margin:0 auto
This would effectively center align your entire page.
There is some real good information on how to design websites for mobile (iPhone/iPad, etc) on http://bit.ly/rs1npZ
You probably need a viewport meta tag. Check the link for info on what this does and which to choose. http://www.allenpike.com/2010/choosing-a-viewport-for-ipad-sites/
I had the same problem.
for my part, the page was broken because of div elements bigger than their container.
i fixed it by playing with overflow-x property.
You may try putting overflow-x:hidden; on your containers.
I had the same problem. Here is how I fixed it:
<meta name="viewport" content="width=device-width, maximum-scale=.9" />

page shifts to the left when rotating iPad from landscape to portrait

I am using CSS media queries to create a web site with responsive design. When I open my test page on the iPad in either landscape or in portrait orientation, it looks fine.
However, when I switch from landscape to portrait mode, the page is shifted to the left. I can tell that the correct CSS is loading because other things on the page change. I can also drag the page to the right and it appears exactly as it does if I had opened the page in portrait initially.
I have my viewport set to:
meta id="view" name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"
I added JavaScript to fix the iOS viewport scaling bug which used to cause the page to be zoomed in when switching from portrait to landscape. (I used the solution described here: https://gist.github.com/901295 )
I'm having problems finding the name for the bug I'm experiencing when switching from landscape to portrait. Has anyone else seen this or know how to fix?
The problem owner says that she "can also drag the page to the right and it appears exactly as it does if I had opened the page in portrait initially."
This makes me think that, for some unknown reason (a bug?), the page is scrolled to the left at an orientation change to portrait mode (otherwise you wouldn't be able to drag it back).
I had a similar issue and solved it with the following JavaScript workaround:
// ...
// Optionally add a conditional here to check whether we are in Mobile Safari.
// ...
window.addEventListener('orientationchange', function() {
if (window.orientation == 0 || window.orientation == 180) {
// Reset scroll position if in portrait mode.
window.scrollTo(0, 0);
}
}, false);
Maybe this will work for others too.
I managed to sort my similar issue out - perhaps this will work for you?
You'll need to work out if it's a particular div or other element that's causing it by deleting/reinstating different bits and retesting the page. Once you've worked it out try adding an overflow: hidden property to that element in your CSS - I used overflow-x: hiddensince my issue was horizontal scrolling but you may need to vary it.
Hope this is of use... good luck!
Jereon, your JavaScript worked for me. My viewport is:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
I'm using the Drupal Corporate Clean responsive theme. I have not had this problem using the Omega responsive theme framework.
The solution for this is as proposed by #ellawson
Problem is caused by some element not being scaled correctly by the browser when rotating the device. Find that element and apply overflow: hidden; or overflow-x: hidden; as he says.
Note: this question is a duplicate. I'll post the gist of my answer here.
2015 update
All the other answers are unfortunately incorrect, outdated, or misguided. Here's what works:
window.addEventListener('orientationchange', function () {
var originalBodyStyle = getComputedStyle(document.body).getPropertyValue('display');
document.body.style.display='none';
setTimeout(function () {
document.body.style.display = originalBodyStyle;
}, 10);
});
The code listens to the orientationchange event and forced a re-flow of the body element by hiding it and showing it 10 miliseconds later. It does not depend on any <meta> tags or media queries.
You said,
When I open my test page on the iPad in either landscape or in portrait orientation, it looks fine. However, when I switch from landscape to portrait mode, the page is shifted to the left
That is key. You just need to force a re-paint of the body.
Answers that suggest adding <meta name="viewport" content="width=device-width, initial-scale=1.0"> or variations thereof, as of Safari 7, no longer wors. Here's a demo. To make sure you see how it doesn't work, start with the iPad in landscape mode, load the page, then rotate. Notice the page doesn't expand to full height, despite using flexbox all the way.
Compare that to this page, where we use the hide/show body technique in production.
I came across this problem with an iPad and applied html { overflow-x:hidden; } . That seems to have resolved the issue.
try adding the following setting to your content properties: maximum-scale=1
or try this: user-scalable=no
here is the ios documentation

Resources