Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 滚动经过特定div时隐藏div_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 滚动经过特定div时隐藏div

Javascript 滚动经过特定div时隐藏div,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一个幻灯片,高度设置为自动,所以任何高度图像都可以显示。在该幻灯片中,我有两个箭头,它们被包装在一个div中,类为.center。箭头位于固定位置,因此滚动时箭头将跟随。当您滚动div.center时,将显示分配给div=“center”的功能 我遇到的问题是,一旦我滚动过幻灯片放映div,箭头仍然存在。但当我向上滚动经过幻灯片放映div时,箭头被隐藏了 当我向下滚动到div 2或幻灯片放映结束时,如果有一类cs滑块,中心将隐藏,如何设置脚本 $(window).scroll(functi

我有一个幻灯片,高度设置为自动,所以任何高度图像都可以显示。在该幻灯片中,我有两个箭头,它们被包装在一个div中,类为.center。箭头位于固定位置,因此滚动时箭头将跟随。当您滚动div.center时,将显示分配给div=“center”的功能

我遇到的问题是,一旦我滚动过幻灯片放映div,箭头仍然存在。但当我向上滚动经过幻灯片放映div时,箭头被隐藏了

当我向下滚动到div 2或幻灯片放映结束时,如果有一类cs滑块,中心将隐藏,如何设置脚本

 $(window).scroll(function() {
    $(".center").each( function() {
      if( $(window).scrollTop() > $(this).offset().top - 150 ) {
        $(this).css('opacity',1);
      } else {
        $(this).css('opacity',0);
      }
    }); 
 });
HTML


试着使用下面的方法

$(this).css('display', 'none');

我为此制作了一个jQuery插件,也许你会发现它很有用:我有点困惑,你不想显示任何溢出吗?如果是,请尝试CSS溢出:无;如果有点混乱,我很抱歉。我想要的是将该分区限制在第1分区。因此,当您滚动到div 1时,箭头将在您滚动到div 1时显示,现在在div 2上,我希望箭头淡出@iAnwise我会看看你的插件@JacobGray我忘了那些链接><你是想在div到达窗口顶部时淡出它吗?
 cs-slider .slides  { margin:0 auto; max-width:800px; display:block; z-index:1}
 .cs-slider             { position:relative; text-align:center; padding:4em 0em 1em 0em;}
 .center                    {opacity: 0; }
 #prev, #next               { position:fixed; top: 0%; width: 10%; height: 200px; cursor: pointer; text-indent:-9999px;}
 #prev                      { left: 0;  background: url(http://malsup.github.com/images/left.png) 50% 50% no-repeat; }
 #next                      { right: 0; background: url(http://malsup.github.com/images/right.png) 50% 50% no-repeat;}
 #prev:hover, #next:hover   { opacity: .7; filter: alpha(opacity=70) }
 .disabled                  { opacity: .5; filter:alpha(opacity=50); }
$(this).css('display', 'none');