如何使用CSS媒体查询将背景图像缩放到查看窗口

如何使用CSS媒体查询将背景图像缩放到查看窗口,css,mobile,mobile-safari,background-image,media-queries,Css,Mobile,Mobile Safari,Background Image,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:

我将这张大图作为网站的背景:

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%;
}

但是在我的移动设备(iPhone4S-Safari)上,
后台附件:fixed
似乎没有在桌面上产生相同的效果。为什么会这样?我可以使用媒体查询来解决这个问题吗?

试试这个-处理背景图像并不总是需要媒体查询。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%; 
}   

到底发生了什么?你可以发布一个链接进行调查吗?Safari的移动版可能不支持
后台附件:已修复
。不幸的是,看看封面和固定无重复背景在Android平板电脑、肖像模式下不起作用。在css中添加html{height:100%,width:100%}。@arp-wow-just-wow。谢谢这解决了我的问题,背景图像不显示在手机上一致!