javascript - 背景图片
问题描述
我有一个带有背景图片和一些内容的网页。我的问题是图像在背景中是全屏的,但是由于内容不是页面,当我向下滚动时,我看到的内容没有图像。
如何扩展背景图像以使其即使在向下滚动后也能覆盖整个内容?
.backImage {
background: url('./images/panoramiki.jpg');
background-size: 100%;
height: 100%;
position: absolute;
left: 0;
right: 0;
z-index: -1;
filter: blur(5px);
-webkit-filter: blur(5px);
background-position: center;
background-repeat: no-repeat;
background-repeat: repeat;
background-size: cover;
<div class="backImage"> </div>
解决方案
您正在寻找 css 属性“背景附件” - 这将导致图像不会随窗口滚动
https://www.w3schools.com/CSSref/pr_background-attachment.asp
.backImage {
background-size: 100%;
height: 100%;
position: absolute;
left: 0;
right: 0;
z-index: -1;
filter: blur(5px);
-webkit-filter: blur(5px);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
推荐阅读
- python - 如果已经以特定模式出现,则排除 pandas 数据框中的值
- scala - Datastax spark cassandra 连接器与 RetryPolicy 将 DF 写入 cassandra 表
- reactjs - 与受控组件的外部交互
- php - Close CSS only lightbox by clicking background without using Js
- javascript - javascript for循环中的异步调用
- c++ - 为什么可以通过野指针调用成员函数
- gensim - 如何保存为 gensim word2vec 文件?
- python - 在 MatplotLib Barplot 中创建随绘图大小缩放的文本
- python - 如果数字除以多个连续的零,则 Python 将列表拆分为子列表
- arrays - Eloquent、PostgreSQL JSONB 和嵌套数组