我需要一个固定的背景来获得浏览器的大小,它保持那个大小,所以内容会向上向下、向左、向右滚动,但背景在后面保持固定。 这可以用 ipad2 实现吗?
background: url("....") no-repeat fixed;
background-size: auto;
background-repeat: no-repeat;
background-attachment: fixed;
有了这个,背景以正确的大小加载,但在滚动时它会滚动到并显示背景颜色。
最佳答案
为此,您可以使用 background-size: cover;
我不确定我是否理解这个问题。如果目标是设计特定于 iPad 2 的背景,您可以考虑 iPad 的分辨率来做类似的事情,即 How large is the usable area in iPad Safari
@media screen and (max-width:1024px) {
body {
background:url(your-1024x690-image) fixed no-repeat; /*landscape background*/
}
}
@media screen and (max-width:768px) {
body {
background:url(your-768x946-image) fixed no-repeat; /*portrait background*/
}
}
还没有测试过,但应该可以。
关于ios - css ipad 2 网站内容在背景上滚动固定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18084517/