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.
Related
I want my site's width to automatically fit on the iPhone portrait screen (testing on an iPhone 5). I currently have the width CSS set to 100% and am using this meta viewport tag:
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />
This technique was recommended by this question: Website does not automatically fit to iphone screen
It doesn't work for me though. The site width is still way wider than the iPhone portrait screen.
How can I get the site width to automatically fit on the iPhone portrait screen?
Make sure the viewport is configured correctly:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
Make sure you don't have content that is wider than the viewport.
For instance if you have an image that is wider than the viewport set the CSS to
max-width:100%;
I think you may just be off a little. This is what works for me.
<meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1.0,maximum-scale=1.0" />
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'm using this template for wordpress:
http://demos.itsmattadams.com/jetwire/
When I try to load on iphone/ipad, the page don't fit to all wide because only show a portion. I don't want horizontal scroll either.
If I open the theme from a ThemeForest link, works good (maybe for the iframe?):
http://themeforest.net/item/jetwire-powerful-wordpress-blog-theme/full_screen_preview/2919709
I tried to change the main container width to 960px, but don't work.
Could somebody help me?
Remove this line
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
The site should then automatically fit inside the viewport. This line is basically telling the device to take the pixelwidth of the device (width=device-width) and match it to your site, by 'zooming in'.
Say your site is 960px wide, and the device is 320px wide; it will then only show the leftmost part (320px wide) of the site, leaving 640px 'flowing over' to the right.
Not specifying a viewport width will force the device to show the full site.
I currently have an image on my site which is a lot larger than usual, but the website cuts off the image at each side dependant on the width of each users monitor, which is fine.
However, on an iPad/mobile device, the whole image is always showing, which is pushing the whole site to the left and also leaving a large area of white space to the right.
Any advice on how to ensure the iPad cuts off the image as the web browsers are doing would be appreciated.
I have used the following in my header
<meta name="viewport" content="user-scalable=yes, width=980px">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=980">
Many thanks
Put this at the time of your of definition of UIWebView
webView.frame=self.view.bounds;
webView.scalesPageToFit = YES;
So user will zoom in and zoom out according to his/her need to read the content.
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/