简体   繁体   English

背景图片在iOS上无法正确缩放

[英]Background image not scaling properly on iOS

Problem is that background images are not scaling properly on iOS devices, it's a responsive site and at least on desktop browsers it does scale great even on very small resolutions.. But when I test on iPhone/iPad it doesn't seem to be working that way. 问题是背景图像在iOS设备上无法正确缩放,这是一个响应式网站,至少在台式机浏览器上,即使在很小的分辨率下,它也确实可以很好地缩放。。但是当我在iPhone / iPad上测试时,它似乎无法正常工作那样。

The page is http://litoplas.net16.net/como.html (it's an internal presentation for meetings and phorums, it won't be a public link, and my customer wants his representatives to use iPads, which is the reason solving this is very important). 该页面为http://litoplas.net16.net/como.html (这是会议和演讲的内部演示,它不是公共链接,我的客户希望其代表使用iPad,这就是解决问题的原因这个非常重要)。

Here's an example of the CSS of a section I'm using with a background image: 这是我与背景图片一起使用的部分CSS的示例:

.corte {
background: url(../images/corte.jpg) no-repeat center center fixed;
background-size: cover;
padding-bottom: 30%;

} }

And as I said, the background images are scaling nicely on desktop browsers...They won't do the same on iOs! 就像我说的,背景图片在桌面浏览器上可以很好地缩放...在iO上它们不会做同样的事情!

Thanks in advance guys, I spent a lot of time searching and trying to figure this out, hopefully you'll have some answers for me! 在此先感谢大家,我花了很多时间进行搜索并尝试找出答案,希望您能为我提供一些答案! :) :)

It appears to be your shorthand rule: background: url(../images/bannercalidad.jpg) no-repeat fixed; 这似乎是您的速记规则: background: url(../images/bannercalidad.jpg) no-repeat fixed;

More specifically it is the background-attachment: fixed that is causing the issues. 更具体地说,是导致问题的是background-attachment: fixed If I add a new rule of background-attachment: scroll then the image is no longer zoomed way far in to the upper-left corner. 如果我添加了一个新的background-attachment: scroll规则background-attachment: scroll则图像将不再放大到左上角。 This may not solve all your problems but it will get you on the right path. 这可能无法解决您的所有问题,但可以使您走上正确的道路。

You need to have the following rule applied for each <section> like so: 您需要对每个<section>应用以下规则,如下所示:

background-size: 100% auto;

This fixed the problem for me using an iOS 7 simulator. 这使用iOS 7模拟器为我解决了该问题。

background-attachment: scroll; worked for me. 为我工作。 You should accept @Fernker's answer. 您应该接受@Fernker的回答。

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

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