【发布时间】:2014-04-04 04:49:41
【问题描述】:
我的网站的背景图片在 Chrome 和 Safari 中使用 background-size:cover 很好地调整了大小,但是当我在 ipad 或 iphone 上测试我的网站时,CSS 背景图片真的被放大了,看起来很糟糕。我在这里阅读了很多与此相关的其他问题,但没有一个能解决我的问题。
HTML
<div class="background">
</div><!--background-->
.background 没有容器,是屏幕的 100% 宽度。
CSS
.background {
height:600px;
width:100%;
position:relative;
background: url(css/img/strand.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
【问题讨论】:
-
试试这个:width:auto;
-
你设置
viewport了吗?例如:<meta name="viewport" content="width=device-width, initial-scale=1"> -
@Ruddy 是的,我正在使用
<meta name="viewport" content="width=device-width, initial-scale=1.0"> -
@AndrewChappell 我认为你应该看看this。
-
我试过 width:auto 但没用