views:

7493

answers:

3

Hi,

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?

+4  A: 

You should definetely create a separate stylesheet especially for ipad. You can use a line like the following for declaring a CSS for the iPad:

<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 advise 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 line like the one I placed at the beginning of my response.

If you have a background of a picture that is 2000x1500 for the ipad version you can reduce it to fit the ipad and that's it. If that's the only thing you've got a problem with. I'd say you should reduce the size of the image to 1024 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/

UXdesigner
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!
favo
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 : http://matthewjamestaylor.com/blog/ipad-layout-with-landscape-portrait-modes
UXdesigner
Just an addition to answer given by @UXdesigner - make use of `<!--[if IE]>....<![endif]-->` tags to not break the site in IE.
ShiVik
A: 

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.

sticky IT
A: 

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

Owen Denham