我有这个大图像作为网站的背景:
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%; }
但是在我的移动设备(iPhone 4S – Safari)上,后台附件:固定似乎与桌面上没有相同的效果.为什么这样,我可以使用媒体查询来解决这个问题吗?
解决方法
试试这个 – 你并不总是需要媒体查询来处理背景图像. 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%; }
原文地址:https://www.jb51.cc/css/217646.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。