background-size:封面不适用于iOS [英] background-size: cover not working on iOS
问题描述
这是我的代码:
background-color:#fff;
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-position: center center;
它适用于台式机,iPad和Android手机:
It's working on desktop, iPad and Android mobile:
在iPhone上的Chrome和Safari上,背景太大了:
On Chrome and Safari on iPhone, the background is too big:
推荐答案
当你有时会发生这种情况背景附件:固定
。在移动设备上,我通常会在 @media
查询中放置 background-attachment:scroll
。
This happens when you have background-attachment:fixed
. On mobile, I usually put background-attachment:scroll
inside of a @media
query.
@RyanKimber指出,修复附加图像使用整个< body>
尺寸。在移动设备上,这可能会变得非常高,从而将您的图像吹走。将附件设置回滚动
可以使封面图像在自己的容器内拉伸。
As @RyanKimber pointed out, fixed attached images use the whole <body>
size. On mobile this can get really tall which blows your image out. Setting the attachment back to scroll
allows your cover image to stretch within its own container.
这篇关于background-size:封面不适用于iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!