html - 静态图像背景和滚动内容 css
问题描述
我想创建一个网页,在整个滚动过程中,背景需要说同样的话。因此,网页的真实内容就像漂浮在背景上一样。
抱歉,我没有任何例子,但这就像苹果有时在展示他们的 iPhone 芯片时所做的那样:有一段时间,页面保持相同的电子电路背景,但芯片规格(如速度)不断出现和滚动
解决方案
您可以简单地使用:
body {
background-image: url("...");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed; /* This is what makes the background seem to be staying in the same position */
}
但是,如果背景很大,可能会导致滚动效果变慢。
推荐阅读
- macports - 升级 macports 时如何解决请求的变体错误
- android - 如何从“onDataChange”侦听器内部将字符串添加到 ArrayList?
- docker - 如何在 Kubernetes 中将用于容器的 Docker 映像的摘要作为环境变量传递
- r - R 中的 Twitter API - Geo 的关注者数量
- php - 如何在foreach中获取当前数组键
- node.js - 如何在没有 createdAt 字段的情况下按年龄升序对 mongodb 查询结果进行排序?(新到旧)
- android - BasicNetwork.performRequest:Volley 的意外响应代码 422
- iis-7.5 - 主图标未加载到 Office Web 插件中,因为“承诺被拒绝”
- date - 如何防止 Tableau 自动转换日期格式?
- r - 在 HPC 集群中调用 ncdf4 nc_open 时 R 挂起