html - CSS-如何设置div在用户滚动时出现

标签 html css twitter-bootstrap twitter-bootstrap-3

我目前有一个网站 http://webdevtutorials.net它有一个用 Bootstrap 制作的全屏轮播。当用户向下滚动时,我想要一个半透明的 div 向上滑动。这是我目前拥有的代码:

<style>
        html, body { height:100%; }
        .carousel, .item, .active { height:100%; position:fixed; }
        .carousel-inner { height:100%; }

        @media screen and ( max-width: 350px ) {
            .carousel-caption {
                margin-bottom: 10%;
            }
        }

        @media screen and ( min-width: 350px ) {
            .carousel-caption {
                margin-bottom: 15%;
            }
        }

        #nav {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 10;
            margin-top: 20px;
            margin-bottom: -90px;
        }

        #content {
            position: absolute;
            background-color: rgba(255, 255, 255, 0.85);
            top: 0;
            left: 0;
            right: 0;
            z-index: 5;
            margin-top: 100%;
        }
    </style>

网站上看到的3个导航按钮是这样的:

<div id="nav" class="container">

轮播图是这样的:

<div id="carousel" class="carousel slide" data-interval="9000" data-ride="carousel">

我想要向上滑动的 div 是这样的:

<div class="row" id="content">

如果你在网站上看,如果你调整窗口大小,div 可能会出现(我不知道为什么)。我正在使用 twitter bootstrap 并希望该网站能够响应。 有谁明白我的意思或有可能的解决方案吗?

编辑: 用户名是guest 密码是橙色的 对不起,我忘了包括他们......

最佳答案

您需要使用scrollTopscroll

演示 http://jsfiddle.net/ZyKar/529/

$(document).scroll(function () {
    var y = $(this).scrollTop();
    if (y > 300) {
        $('.bottomMenu').slideDown();
    } else {
        $('.bottomMenu').slideUp();
    }

});

关于html - CSS-如何设置div在用户滚动时出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19893792/

相关文章:

html - 导航栏中图像的垂直对齐

html - CSS:如何在两列中显示相同的元素,元素之间没有间距?

css - 从其组合框中移走字段标签

css - flex-basis 属性集究竟是什么?

javascript - 发送空白电子邮件的 PHP 脚本无法获取发布数据

html - 将 label 标记用于具有多行表格单元格的表格中的多行

html - 与表格单元格垂直对齐

javascript - 复选框切换选项

javascript - 为字符串中的每个句子添加 html 标签

javascript - 使用 JS 更改 div 的内容会破坏我在手机上的 Bootstrap 行对齐