Viewport and Scale for the iPhone -...

User 508542 Photo


Registered User
17 posts

Testing my initial design, I found that the width of my page did not match the 320px screen width of the iPhone - there was a significant overlap area outside of the screen that had to be swiped to view. There is no Min Width set, so I don't see why the page does not shrink fully. Exactly the same behaviour shows in landscape mode (480px).

I fixed it by deleting the " initial-scale=1.0" from the meta viewport line in the header of the index.html. Now the page shrinks to fit exactly the iPhone screen, portrait or landscape, and no apparent change to the correct behaviour on iPad and PC screens.

Why does RLM add "initial-scale=1.0"? What effect does it have? Should I look for a different fix for the iPhone display question?
Thanks for any guidance.
User 187934 Photo


Senior Advisor
20,190 posts

Does it still look correct when you rotate from portrait to landscape?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 271657 Photo


Ambassador
3,816 posts

Does your layout use Coffeegrinder or Bootstrap?
Could you share a link so iphone users here can get a look at it?

Check this out:
https://css-tricks.com/probably-use-initial-scale1/
I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
https://www.callendales.com
User 1948478 Photo


Senior Advisor
1,850 posts

Graham,
Take a close look at the css for the specific elements that overflow the device width. Make sure that the total width, including padding, border and margin, of an element does not exceed 100%. This can easily happen, for example, if you specify margins in units of "em" or "px", even if you specify element width below 100%.

As an example, if you specify an element width of 95% and left and right margins of 1em, the total width will be 336px for a device width of 320px, thereby overflowing and requiring horizontal scrolling. (This assumes 1em=16px, default box sizing, no border, etc...)

For larger device widths, this would not be a problem, since the 2em total margin would be a diminishing percentage of increasing, available container width.

This is just one of many possible causes for horizontal overflow on smaller devices in responsive design.
As explained in the link provided by paintbrush, you should definitely keep the "initial-scale=1.0" in the meta tag.
User 508542 Photo


Registered User
17 posts

Thanks, guys. I thought I'd posted a reply last week but anyway, since then the issue is resolved, and I'm not sure how, 'cos I'm onto my 14th revision now! It might have been due to something overhanging the width, as Per suggests - maybe in a Select dropdown box that iOS was not handling well. I found it's really important to check the behaviour of every element in both Class and ID settings, at every viewport width, and it's very easy to miss something.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.