小编Jak*_*kob的帖子

防止jQuery跳转到底部(使用fadeIn时)

我用jQuery创建了一些淡入淡出的div,如果用户向下滚动一下我会遇到问题.如果您不在页面的顶部,当新div消失时,它将始终跳到底部.

这是我的代码:

<style>
#overflowwrap {
   overflow:hidden !important;
}
</style>

<div id="overflowwrap">
   <div id="five" style="display: none;">a lot of content</div>
   <div id="four" style="display: none;">a lot of content</div>
   <div id="three" style="display: none;">a lot of content</div>
   <div id="two" style="display: none;">a lot of content</div>
   <div id="one" style="display: none;">a lot of content</div>
</div>

<script>
$('#overflowwrap').css('max-height',$(window).height());

$("#one").fadeIn(500);
setTimeout( function show() {
   $("#two").fadeIn(500);
}, 3000);
setTimeout( function show() {
   $("#three").fadeIn(500);
}, 6000);
setTimeout( function show() {
   $("#four").fadeIn(500);
}, 9000);
setTimeout( function show() {
   $("#five").fadeIn(500);
}, 12000);
</script>
Run Code Online (Sandbox Code Playgroud)

更新: …

html javascript css jquery

6
推荐指数
1
解决办法
575
查看次数

标签 统计

css ×1

html ×1

javascript ×1

jquery ×1