Show Div when scroll position

前端 未结 3 1694
野性不改
野性不改 2020-11-27 11:42

First of all i would like to refer to this website: http://annasafroncik.it/ I love the way the animations come into view. Is it hard to create a similar function in jquery?

3条回答
  •  有刺的猬
    2020-11-27 12:31

    Try this . It worked for me

    $(document).scroll(function() {
      var y = $(this).scrollTop();
      if (y > 400) {
        $("body").addClass("allowshow");
      } else {
        $("body").removeClass("allowshow");
      }
    });
    

    and the css for this is

    .showmydiv{display:block}
    

提交回复
热议问题