简体   繁体   English

iPad iPhone缩放背景图片

[英]iPad iPhone scale background images

Just wondering if anyone else has experienced the iPad/iPhone scaling their background images down to fit the view port. 只是想知道是否有其他人经历过iPad / iPhone缩放他们的背景图像以适应视口。

In my case, I'm swapping out background images via javascript, and the new background images are super wide to fit large displays. 在我的情况下,我通过javascript交换背景图像,新的背景图像超宽,适合大型显示器。 However, the iPad is scaling down the background images that are added to the DOM via javascript. 但是,iPad正在缩小通过javascript添加到DOM的背景图像。 I solved this by using "-webkit-background-size" set to the size that the image should be, but this causes the background image to be stretched and pixelated. 我通过使用“-webkit-background-size”设置为图像应该的大小来解决这个问题,但这会导致背景图像被拉伸和像素化。

这适用于iPad:

-webkit-background-size: length_x length_y;

The iphoneOS scales every picture with above 2 million pixels (width*height) 50% down. iphoneOS将每张图片缩放到200万像素(宽*高)50%以下。 I managed it with spliting the background into two pictures. 我通过将背景分成两张照片来管理它。

您所要做的就是在页面中添加此元标记,以防止缩放背景图像。

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

First of all, if you export your image as a 32 bit png (I use Fireworks to do so), and use that png in your background instead of a jpg file, IOS won't scale the image. 首先,如果您将图像导出为32位png(我使用Fireworks这样做),并在背景中使用该png而不是jpg文件,IOS将不会缩放图像。 Works like a charm, and the size is about the same as a jpg with 100% quality (slightly smaller actually) 像魅力一样,大小与100%质量的jpg大致相同(实际上略小)

Also, aditionally for a better experience in ipad / iphone, you should: 另外,为了获得更好的ipad / iphone体验,你应该:

a) set a min with do the body tag (mine is usually 980px) a)用身体标签设置一个min(我的通常是980px)

body {
    min-width: 980px;
}


b) set the same width to the viewport meta tag b)将相同的宽度设置为视口元标记

<meta name="viewport" content="width=980px">


Users should now be able to: 用户现在应该能够:
- see the design as you have created it - 看看你创造的设计
- zoom the content (wich they couldn't if you used "initial-scale=1, maximum-scale=1" on the viewport meta tag) - 缩放内容(如果在视口元标记上使用“initial-scale = 1,maximum-scale = 1”,则不能缩放内容)
- change the device landscape to portrait and vice versa with no issues - 将设备格局更改为纵向,反之亦然

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM