首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何应用溢出:隐藏;?

如何应用溢出:隐藏;?
EN

Stack Overflow用户
提问于 2014-07-24 20:49:25
回答 2查看 60关注 0票数 0

当超出#页面的限制时,我需要隐藏..content部分。

我需要使用溢出:隐藏;但是我无法获得在#页面上应用所需的结果。

知道怎么修吗?

http://jsfiddle.net/Pet8X/1/

代码语言:javascript
复制
   <div id="btn-up" onclick="moveUp();">UP</div>
    <div id="btn-down" onclick="moveDown();">DOWN</div>
    <div id="page">
        <div id="bar-header">Header</div>
        <div id="content">
            <div class="content-section item1 ">
                <a name="anchor-1"></a>
                <h2>Content 1</h2>
            </div>
            <div class="content-section item2">
                <a name="anchor-2"></a>
                <h2>Content 2</h2>
            </div>
            <div class="content-section item3">
                <a name="anchor-3"></a>
                <h2>Content 3</h2>
            </div>
            <div class="content-section item4">
                <a name="anchor-4"></a>
                <h2>Content 4</h2>
            </div>
        </div>
        <div id="bar-footer">Footer</div>
    </div>


/*resetter */
    h1, h2, h3, h4, h5, h6 {
        margin: 0;
        padding: 0;
    }

    body {
        margin: 0;
        padding: 0;
        background: transparent;
        width: 500px;
        height: 200px;
    }

    ul {
        list-style-type: none;
        margin: 0px;
        padding: 0px;
    }

    #bar-header, #bar-footer {
        position: fixed;
        left: 0px;
        width: 500px;
        height: 30px;
        z-index: 100;
        background-color: rgba(50,50,50,0.5);
        text-align: center;
    }

    #bar-header {
        top: 0px;
    }

    #bar-footer {
        top: 690px;
    }

    #btn-up, #btn-down {
        position: fixed;
        left: 1230px;
        width: 50px;
        height: 50px;
        background-color: yellow;
        outline: 1px solid black;
        z-index: 200;
    }

    #btn-up {
        top: 0px;
    }

    #btn-down {
        top: 50px;
    }

    #content {
        position: fixed;
    }

    #content-inner {
        overflow: hidden;
    }

    .content-section {
        background-color: lightgray;
        outline: 1px solid black;
        width: 50px;
    }
    /* content sizes */
    .item1 { /* top is 0 */
        height: 200px;
    }

    .item2 { /* top is 200 */
        height: 400px;
    }

    .item3 { /* top is 600 */
        height: 600px;
    }

    .item4 {
        height: 800px;
    }

    .content-section h2 {
        position: relative;
        top: 30px; /**avoid to go under the header bar*/
    }

    .active {
        background-color: violet !important;
    }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-07-24 20:56:55

您正在错误地引用侧栏容器的ID。

你的规则说

代码语言:javascript
复制
#content {
    position: fixed;
}

#content-inner {
    overflow: hidden;
}

但是没有元素#content-inner

用这个代替:

代码语言:javascript
复制
#content{
    position: fixed;
    overflow: hidden;
}

这导致:

小提琴

票数 2
EN

Stack Overflow用户

发布于 2014-07-24 20:55:20

只需将溢出-隐藏到#内容

代码语言:javascript
复制
#content{
position: fixed;
overflow: hidden;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24943694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档