[英]Background Image not showing up on iphone/tablet
I have a background image that's not showing up on the iphone/tablet! 我的iphone /平板电脑上没有显示背景图片! The funny thing is that if you use a laptop but set the window size to that of an iphone/tablet, it still shows up (try resizing the site).
有趣的是,如果您使用笔记本电脑,但将窗口大小设置为iPhone /平板电脑的大小,它仍然会显示出来(尝试调整站点大小)。
#intro {
background: url('imageurlhere') no-repeat right fixed;
background-color: #fdfdfd;
-webkit-background-size: 50% 125%;
-moz-background-size: auto 125%;
-o-background-size: auto 125%;
background-size: auto 125%;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='imageurlhere', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='imageurlhere', sizingMethod='scale')";
padding-top: 10%;
}
if i take off the "fixed" parameter, it will show but parallax will be gone. 如果我取消“固定”参数,它将显示但视差将消失。
Is there any way to fix this? 有没有什么办法解决这一问题? Thanks!
谢谢!
The problem was in the position-y: fixed of the convenience property. 问题出在位置y:固定了便利属性。
Safari on iOS didn't recognize fixed
so it ignored the whole rule (see attached screenshot). iOS上的Safari无法识别
fixed
因此它忽略了整个规则(请参阅随附的屏幕截图)。
Remove: 去掉:
background: url(http://i.imgur.com/CVJVeWw.jpg) no-repeat right fixed;
and add instead: 并添加:
background-repeat: no-repeat;
background-size: auto 125%;
background-position-x: right;
background-position-y: fixed;
background-image: url(http://i.imgur.com/CVJVeWw.jpg);
Update see background-position-y
and background-attachment: fixed
更新请参阅
background-position-y
和background-attachment: fixed
I played with this a bit more to see if I could get it working a bit better for you. 我玩了一点,看是否可以为您更好地工作。 For some reason, when both
background-attachment: fixed;
由于某种原因,当两个
background-attachment: fixed;
都background-attachment: fixed;
and background-position-x: right;
and
background-position-x: right;
are specified on iOS 6x, the background goes missing. 是在iOS 6x上指定的,背景丢失了。 However, by resetting
background-attachment: fixed;
但是,通过重置
background-attachment: fixed;
to initial
the image displays although you do lose the parallax. 到
initial
虽然你失去了视差的图像显示。
So: try this for desktop: 所以:在桌面上尝试一下:
#intro {
background-attachment: fixed;
background-repeat: no-repeat;
background-position-x: right;
background-position-y: center;
background-image: url(http://i.imgur.com/rKJbwgL.jpg);
background-color: #fdfdfd;
-webkit-background-size: 110% 110%;
-moz-background-size: auto 125%;
-o-background-size: auto 125%;
background-size: auto 110%;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://i.imgur.com/rKJbwgL.jpg', sizingMethod='scale');
-ms-filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://i.imgur.com/rKJbwgL.jpg', sizingMethod='scale')";
padding-top: 10%;
margin-right: -10%;
}
Then in a media query for phone/tablet, reset background-attachment: 然后在媒体查询中查找电话/平板电脑,重置背景附件:
background-attachment: initial;
Let me know if that works a bit better for you. 让我知道这是否对您更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.