jquery - 滚动显示模糊卡住
问题描述
嗨,我做了一个简单的滚动显示,以便初始 div 下面的 div 不模糊,如图所示,它在 jsfiddle 中完美运行,但是当我将它放入我的网站时它不起作用......一切都只是我的网站是一样的使用 jquery 版本 3.2.1 min js,
如果有人可以让我知道为什么它不能在我的网站上运行,但在 JS fiddle 上运行会很棒!
$(window).scroll(function() {
var revealBlur = 10 - Math.floor($(window).scrollTop() / 15);
if (revealBlur < 0) { revealBlur = 0; }
$('#content2').css({
'-webkit-filter': 'blur('+revealBlur+'px)'
});
});
body {
margin: 0;
}
.content2 {
width: 100%;
height: 300px;
position: sticky;
bottom: 0;
z-index: -1;
background: url(https://placekitten.com/1200/800) no-repeat;
}
.content1 {
width: 100%;
height: 300px;
position: relative;
background: url(https://placekitten.com/1200/800) no-repeat;
}
#content2 {
-webkit-filter: blur(15px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div id="content1" class="content1"></div>
<div id="content2" class="content2">
</div>
https://jsfiddle.net/joshtrose/vr1n8ty7/1/
我正在使用的 jQuery 文件
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
解决方案
position:sticky
chrome 支持的不是很好。你可以从 Can I Use 中查看这些,
根据 Can I use,直到版本 55,它根本不支持,在 56 到当前版本之后,它对 chrome 的支持有限。
推荐阅读
- windows - 使用 Windows cmd 删除搜索后列出的所有 SYMLINK 文件类型?
- ios - Swift:单击每个停止按钮后要求用户输入文本文件名
- macos - 如何从终端将文本更改为 Mac 目录上的不同文本
- mysql - 使用 mysql JOIN 选择数据
- ios - 当用户打开通知时,如何在 SwiftUI 中打开特定视图?
- hook - 附加在 POST 调用中返回的文件
- javascript - 为什么这个 JavaScript ES6 示例中“等待”之后的代码没有运行?
- php - 在 Laravel 存储方法中的 foreach 中保存请求变量
- ssl - vertx HTTPS 服务器在升级到 3.8.4 后停止工作
- java - 意图不断返回 null