Creating blur effect with css and jQuery on scroll

前端 未结 2 2085
暖寄归人
暖寄归人 2021-01-04 18:54

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

&         


        
2条回答
  •  盖世英雄少女心
    2021-01-04 19:01

    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;
    }
    
    

    jsfiddle https://jsfiddle.net/2dmxLnuy/5/

提交回复
热议问题