gre*_*ner 5 css mobile background-image mobile-safari media-queries
我有这个大图像作为网站的背景:
body {
background: #000 url(/assets/img/living.jpg) no-repeat center center;
background-attachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height:100%;
}
Run Code Online (Sandbox Code Playgroud)
但是在我的移动设备(iPhone 4S - Safari)上,它background-attachment: fixed似乎没有像在桌面上那样具有相同的效果.为什么这样,我可以使用媒体查询来解决这个问题吗?
Gat*_*sby 18
试试这个 - 你并不总是需要媒体查询来处理背景图像.CSS3 background-size:cover属性可以自行处理所有这些.以下在我测试过的所有移动设备上都能很好地适用于我 - 尤其适用于Android,移动版浏览器和所有平板电脑.
body {
background-image: url(/assets/img/living.jpg);
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height:100%;
width:100%;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
35541 次 |
| 最近记录: |