I am trying to create blur effect when the user scrolls up and down the browser window using css and jquery. Here is my code.
HTML
&
For "blur" effect , try utilizing css
filter blur(Npx)
, where N
is a number; px
css
pixel units e.g.; 4px
var hideThatKitty = $('.out').innerHeight();
$(window).on('scroll', function () {
hideThatKitty = hideThatKitty / $('.this-div-kills-browsers').offset().top
$('.out')
.css({"webkit-filter": "blur(4px)",
"moz-filter":"blur(4px)",
"ms-filter":"blur(4px)",
"o-filter":"blur(4px)",
"filter":"blur(4px)"});
});
.out {
width: 100%;
height: 800px;
background: url(https://placekitten.com/1200/800) no-repeat;
}
.this-div-kills-browsers {
height: 1000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<div class="out">
<div class="inner"></div>
</div>
<div class="this-div-kills-browsers"></div>
jsfiddle https://jsfiddle.net/2dmxLnuy/5/
Scrolling while bluring an image
Demo
https://jsfiddle.net/vduucu87/
Code
$(window).on('scroll', function () {
var pixs = $(document).scrollTop()
pixs = pixs / 100;
$(".out").css({"-webkit-filter": "blur("+pixs+"px)","filter": "blur("+pixs+"px)" })
});