简体   繁体   English

iPhone无法调整背景图片的大小

[英]Background image not resizing on iPhone

The background image is resizing great here , but not on iPhone (haven't checked iPad). 此处的背景图片调整大小很好,但在iPhone(尚未检查iPad)上却没有。

The image is 1393 x 1098 pixels. 图像为1393 x 1098像素。

Here is my css: 这是我的CSS:

.slider-wrap-blue { 
background:transparent url(/images/fpfbg.jpg) no-repeat center center fixed; 
min-width: 980px;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover; }

Not sure is this is the answer but I noticed you don't have the 'meta viewport' tag in your markup. 不确定这是否是答案,但我注意到您的标记中没有'meta viewport'标签。 Without that, scaling is the same as the desktop and might be throwing this off. 否则,缩放比例将与桌面相同,并且可能会被取消。 I don't have an iPhone with me to look. 我没有iPhone可以看。 Does the problem exist in Android, too? 这个问题在Android中也存在吗?

EDIT: I see you mention it in one of the comments. 编辑:我看到你在评论之一中提到它。 Here is the complete meta tag: 这是完整的元标记:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

A couple of observations. 一些观察。 You have an ad/comment before the doctype. 您在文档类型之前有一个广告/评论。 This puts IE into quirks mode. 这使IE进入怪癖模式。 Remove anything before the doctype to get rid of that problem. 删除doctype之前的所有内容以解决该问题。

Also, you are using XHTML1.1 doctype. 另外,您正在使用XHTML1.1文档类型。 That is for XML applications only and you are serving your pages as HTML. 那仅用于XML应用程序,并且您将页面作为HTML提供。 Use a HTML doctype. 使用HTML文档类型。

I have had problems with images not being able to shrink below their initial sizes. 我遇到了图像无法缩小到其初始尺寸以下的问题。 Maybe it is shrinking down to 1393 x 1098, but will not go any smaller. 也许会缩小到1393 x 1098,但不会变小。 I use a smaller version of the images for the phone and a larger version for tablet and desktop devices. 我在手机上使用较小版本的图片,而在平板电脑和台式机设备上使用较大版本的图片。 I use the user-agent to determine the device that the webpage is running on and display the proper image. 我使用用户代理来确定运行该网页的设备并显示正确的图像。

I would classify this as a comment rather than an answer, but do not have the reputation to leave a comment yet:) 我将其归类为评论而不是答案,但还没有留下评论的名声:)

I had a similar problem on older devices. 我在较旧的设备上遇到了类似的问题。 I changed the image from a jpg to a png and it fixed the background-size problem. 我将图像从jpg更改为png,并解决了背景尺寸问题。

Perhaps try a jQuery plugin like Backstretch . 也许尝试像Backstretch这样的jQuery插件。 It should be a better cross-platform answer. 这应该是更好的跨平台答案。

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

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