【发布时间】:2018-01-09 14:38:45
【问题描述】:
我用于背景的图像(已修复)以 Web 格式显示为 100%,但是当我在 Ipad (1024x768) 上模拟它时,图像停止适应屏幕的宽度,它只填充了大约屏幕高度的 70%。
这是我用于网站格式的 CSS:
.body{
background-image: url("/img/bg.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% auto;
height: 5700px;
width: 100%;
}
这是我用于 Ipad 样式的 CSS:
@media screen and (max-width: 1024px) {
.body{
background-image: url("/img/bg.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% auto;
height: 5700px;
min-width: 1024px;
}
}
我尝试了min-width: 1024px;,因为我发现了一个类似的question 与该建议,但它没有奏效。
【问题讨论】:
-
你可以试试宽度:100vw;?如果有帮助我会写一个答案
-
@Traver 好的,我现在就试试。
-
我已经在背景尺寸(而不是宽度)上尝试过它并且它已经工作了!谢谢!我将在下面发布完整的答案。
-
我看到您将使用 vh/vw 单位。请在下面查看我的答案以获取重要信息