I have a slideshow that has a height set to auto so any height image can be displayed. Within that slideshow I have two arrows which are wrapped in a div with a class of .center. The arrows are at a fixed position so when scrolling the arrows would follow. The function that is assigned to div="center" will display when you scroll over the div .center.
The problem I am having is once I scroll past the slide show div the arrows are still present. But when I scroll up past my slide show div the arrows are hidden.
How can I set up my script for when I scroll down to div 2 or end of slide show which has a class of cs-slider the center will be hidden?
$(window).scroll(function() {
$(".center").each( function() {
if( $(window).scrollTop() > $(this).offset().top - 150 ) {
$(this).css('opacity',1);
} else {
$(this).css('opacity',0);
}
});
});
HTML
<section class="cs-slider" style="margin-bottom: 80px;" >
<div class="center" id="box" >
<a href=# id="prev">Prev</a>
<a href=# id="next">Next</a>
</div>
<div class="slides cycle-slideshow"
data-cycle-fx="fade"
data-cycle-prev="#prev"
data-cycle-next="#next"
data-cycle-pager=".pager"
data-cycle-loader="wait"
data-cycle-swipe=true
data-cycle-swipe-fx=scrollHorz
data-cycle-auto-height=container
data-cycle-center-horz=true
data-cycle-timeout="0"
data-cycle-speed="500"
>
<div class="pager"></div>
</div>
</section><!-- slider -->
<section class="workContent fadeDown"><!-- Hide .center once you scroll over section -->
</section>
CSS
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');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.