我需要的是:
如果你在页面的顶部,就像你重新加载它之后,特定div的CSS不应该改变。现在,如果您进一步滚动到顶部(即使您已经在0处),div应该获得应用了一些CSS的style属性,因此在您再次向下滚动到0之后,该属性应该会被删除。有人知道这是怎么回事吗?我查阅了scrollTop()的jQuery应用程序接口文档,但这并没有让我更清楚。
到目前为止,我已经尝试了:
$(window).scroll(function(){
    if ($(window).scrollTop() < 0){
        $('#profile--heading').css( "height","800px" );
    } else {
        $('#profile--heading').removeAttr("style");
    }
});基本上,这正是谷歌在Google Plus个人资料标题图片中得到的。如果你在页面的顶部,图像应该会变大,在你再次向下滚动后,网站应该首先滚动到0,然后才能进一步滚动。
提前感谢您的努力。
发布于 2017-07-12 00:56:57
如果我正确理解了您的问题,这可能会对您有所帮助:click here
  $(function() {
    $(window).scroll(function() {
      var scroll = $(window).scrollTop(); //current scroll position
      if (scroll >= 100) {
        $("#block").height(1000);//increases the height of the element
      } else if (scroll < 100) {
        $("#block").height(200);//decreases the height of the element
      }
    });
  });https://stackoverflow.com/questions/45038550
复制相似问题