Jquery 面板 + 从顶部检测滚动?

标签 jquery html css scroll panel

我目前正在测试这种类型的面板 jquery: http://codyhouse.co/gem/css-slide-in-panel/

但是当我想检测从顶部滚动以显示一个 div 时:没办法:(

一种检测面板内从顶部滚动的方法?我用这种东西没有结果http://jsfiddle.net/apaul34208/ZyKar/3/

$(document).scroll(function () {
    var y = $(this).scrollTop();
    if (y > 500) {
        $('.cache').fadeIn();
    } else {
        $('.cache').fadeOut();
    }

});

最好的问候,

最佳答案

这是您要找的吗?

http://jsfiddle.net/ZyKar/2327/

HTML

<div class="topMenu"></div>

CSS

body {
    height:1600px;
}
.topMenu {
    display: none;
    position: fixed;
    top: 0;
    width: 100%;
    height: 60px;
    border-bottom: 1px solid #000;
    background: red;
    z-index: 1;
}

Javascript

$(document).scroll(function () {
    var y = $(this).scrollTop();
    if (y > 1) {
        $('.topMenu').fadeIn();
    } else {
        $('.topMenu').fadeOut();
    }

});

关于Jquery 面板 + 从顶部检测滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30758749/

相关文章:

javascript - 你如何使溢出的 float 元素居中?

javascript - 动画滚动功能搞砸了使用移动 View 的触摸控件

html - 在 lg 上只有一个 div 作为 xs 分辨率

javascript - 我无法让我的 jquery 选项卡调用任何 .tab 元素

html - 下拉子菜单不起作用

html - swf叠加问题

javascript - 将毫秒转换为年

jquery - 使用 jQuery 将标签转换为下拉菜单

javascript - 排序和合并数组

html - 使用 Compass 的 Foundation 5 的 SASS/CSS 问题