A way to correct background scaling in iPad's Safari?

62,481

Solution 1

You should definitely create a separate stylesheet for the iPad. You can use the following to do so:

<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="../ipad.css" type="text/css" />

On this link, you will find information about the orientation of your website on the iPad and how to deal with it.

My advice would be, to create a separate stylesheet (css file) for the iPad version of your site, no matter what you do, you should just create it and add a link tag like the one shown above.

If you have a background of a picture that is 2000x1500px for the iPad version, you can reduce it to fit the iPad, if that's the only thing you've got a problem with. I'd say you should reduce the size of the image to 1024px and declare it in the separate stylesheet for the iPad, and you will see the end result.

Let me know how it goes.

BTW you should read this article as well: http://www.inspiredm.com/2010/02/09/ipad-design/

Solution 2

Adding this worked for me when I had a background image on the background canvas...

body{ -webkit-background-size: 2000px 1400px;}

Obviously one has to replace the dimensions with the correct size for the image.

Solution 3

It seems that this issue only occurs on the iPad when you have a background image that is attached the the <body> tag. If you place the background image into a containing div, the issue can be resolved -- this is a great work-around if you don't need to have your background image "fixed", as the techniques to make background fixed work in IE mandate that you use the <body> tag for images.

You can see the difference in these two sites, the first uses the <body> tag for positioning (due to the fixed positioning on the background image) and the second uses a containing div:

http://www.mricsi.com http://www.collinshirsch.com

Hope that helps!

edit -- this is not entirely accurate -- it seems like this is the case only some of the time, and the reason behind why is unclear.

Solution 4

I've got a 5400x556 as a (scrolling) background image in a div. As a .jpg it gets scaled down drastically, as a .png it's fine. The only trouble now is the .png is 5 megs. Grr.

Good call on the separate stylesheets though.

good luck

owen

Share:
62,481

Related videos on Youtube

favo
Author by

favo

:-)

Updated on July 09, 2022

Comments

  • favo
    favo almost 2 years

    I have a website using a huge background image (2000x1500) in a div container (100% x 100%).

    When I open that site on Safari on an iPad it gets scaled down (~40%) in a different proportion than the content (~80%).

    I moved the background to an img-tag in a div with 100% width and 100% height and an overflow setting "hidden". Exactly the same happens.

    Is there a CSS Setting that can help Safari to scale down background images in the same proportion as the content?

  • favo
    favo almost 14 years
    this worked perfect, thanks! i started using a second css with a fixed pixel size for the background container, also thanks for the article -- +1 too!
  • UXdesigner
    UXdesigner almost 14 years
    You're welcome. I just noticed that I made reference to a link in my response, but I didn't post the link: About iPad layout orientation : matthewjamestaylor.com/blog/…
  • vikmalhotra
    vikmalhotra almost 14 years
    Just an addition to answer given by @UXdesigner - make use of <!--[if IE]>....<![endif]--> tags to not break the site in IE.
  • user110857
    user110857 almost 12 years
    >"On this link, you will find information about" @UXdesigner You can 'find' information, or do you intend to say, 'You can designate'?
  • vearutop
    vearutop almost 12 years
    IOS also scales 2mp+ images down, beware stackoverflow.com/questions/2860387/…
  • Christian
    Christian over 11 years
    The new Internet Explorer... oh wait, "device-specific stylesheets" are standardized...
  • Aaron
    Aaron almost 11 years
    So is it safe to say that background-size cover is broken on ipads when using viewport scaling?