繁体   English   中英

滚动时堆叠div

[英]stacking divs when scrolling

我想格式化博客上的帖子,以便在用户向下滚动页面时堆叠“标题div”。 我解释这一点的唯一方法就是通过欺骗和使用z-index来制作一个小小的演示模拟它应该看起来的样子。

我想重新创建此效果,但它适用于博客上的帖子。 这可能吗?

编辑:试图找到一种方法来使用JavaScript创建此效果。

这是当前的css:

body {
    margin: 0;
    padding: 0;
}

h2, h3, p {
    padding: 0px;
    margin: 0px;
}

#container {
    position: relative;
    width: 360px;
    margin: 0px auto;
}

#header {
    position: fixed;
    top: 0px;
    width: 360px;
    height: 60px;
    background: #fff;
    z-index: 10;
}

#right_column {
    width: 360px;
    margin: 60px 0px 0px 0px;
}

    #right_column .first_title {
        position: relative;
        margin: 0px;
        font-size:32px;
        line-height: 30px;
        z-index: 9;
        background: #fff;
    }

    #right_column .first_fixed {
        position: fixed;
        top: 60px;
        z-index:6;
        width: 360px;
        background: #eee;
        border-top: #999 1px solid;
    }

    #right_column .first {
        position: relative;
        z-index: 5;
        background: #fff;
    }

    #right_column .second_title {
        position: relative;
        margin: 0px;
        font-size:32px;
        line-height: 30px;
        z-index: 5;
        background: #fff;
    }

    #right_column .second_fixed {
        width: 360px;
        position: fixed;
        top: 80px;
        z-index: 3;
        border-top: #999 1px solid;
        background: #eee;
    }

    #right-column .second {
        position: relative;
        z-index: 2;
    }

这是标记:

    <h2 class="first_title">This is the article title.</h2>
        <h3 class="first_fixed">This is the article title.</h3>
                 <p class="first">This is some text.</p>
    <h2 class="second_title">This is the article title.</h2>
        <h3 class="second_fixed">This is the article title.</h3>
                <p class="second">This is some text.</p>

我不确定你要求的是什么..我想你正试图替代你已经找到的那个。 在这种情况下,您可能希望查看此示例中的jQuery waypoints插件。您可以定义在滚动页面时触发事件的标记。
这是它的主页

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM