I have fixed background image and upon scroll I want the image to go blur. I know how to do blur in css but do it at specific scroll position.
Here is an example: https://medium.com/good-music/f160ba9e6c52
Any thoughts, examples, advice of snippets will be helpful.
Thanks
This codepen does exactly what you want. With browser support in mind it uses 2 images though instead of blur:
http://codepen.io/sota0805/pen/pqLcv
On your website example ( https://medium.com/good-music/f160ba9e6c52) there is no css "blur" effect.
You can find one normal image: https://d262ilb51hltx0.cloudfront.net/max/1440/1*THFG10B56f4TQOebO1Zd_w.jpeg
And a blurred image: https://d262ilb51hltx0.cloudfront.net/max/1440/gradv/29/81/40/darken/45/blur/20/1*THFG10B56f4TQOebO1Zd_w.jpeg
After superposing those two images, you have to change the opacity of the first one, it's done!
I have only mention the how you can get the position with the scrolling.
For IE,Opera previous bind will not work, so you need to
Hope this might help. Cheers.!
You can blur the element relative to how far you've scrolled.
Here I am using
scrollTop()
to get the amount of pixels the window has scrolled, and then I set the blur on the element to that number divided by 60, which is just an arbitrary number I chose to get the blur I wanted.If you want to add the blur at a certain point, you can use an element on the DOM and the check it's position relative to the window.
If
.element
is less than 450px from the top of the window, the classblur
will be added to it. Your blur class would look something like this:You'll probably want to use a transition with it. Don't forget the vendor prefixes.