ios - css ipad 2 网站内容在背景上滚动固定

标签 ios css web background fixed

我需要一个固定的背景来获得浏览器的大小,它保持那个大小,所以内容会向上向下、向左、向右滚动,但背景在后面保持固定。 这可以用 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/

相关文章:

javascript - 如何从 DOM 中删除 div 及其内容

css - div 的 HTML-CSS 位置问题

html - 如何将我计算机上的图像添加到 css 或 html 中的站点?

javascript - 如果网站刷新,则停止 php 调用的 mysql 服务器运行

ios - UICollectionView 每秒重新加载一次

ios - 检测变换后的 CAShapeLayer 路径上的点击

ios - swift2 将文本文件的内容加载到变量中

ios - 请帮助我了解 IOS 7+ 图标和标题

css - CSS 媒体查询中的分数像素 (Chrome)

jquery - 尝试 "pin"可排序 jQuery <li>,意外行为