【发布时间】:2014-04-24 03:10:57
【问题描述】:
我的网站首页上有一张封面照片,它在桌面上看起来很好,并且随着浏览器大小的变化而缩放,但在移动设备上打开时看起来绝对可怕。
这是我正在使用的:
.first {
width: 100%;
height: 100%;
background-attachment: fixed;
position:relative;
background: url(../photo.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
我也试过这样做:
@media only screen and (max-width: 320px) {
/* Small screen, non-retina */
.first {
background: url(../photo.jpg);
width: 50%;
height: 50%; }
}
@media only screen and (min-resolution: 2dppx) and (max-width: 320px) {
/* Small screen, retina */
.first {
background: url(../photo.jpg);
width: 50%;
height: 50%; }
}
但这没有用。
任何帮助将不胜感激!
【问题讨论】:
-
它是什么样子的?您能否发布该网站的链接或问题的屏幕截图?
-
是的,当然! yudasina.com
-
我认为这个问题可能是由于移动 viewport 以及您使用
fixed属性导致的错误定位/大小的 bg 图像引起的修复文档大小,而不是viewport。
标签: html css responsive-design