【问题标题】:Enable scrollbar for a fixed positionated container为固定位置的容器启用滚动条
【发布时间】:2015-04-27 10:59:46
【问题描述】:

我有一个固定位置的侧边栏,其中包含一些链接:

<nav id="fixedNav">
    <div class="anchors">
        <ul>
          <li><a href="#">test 1</a></li>
          <li><a href="#">test 2</a></li>
          <li><a href="#">test 3</a></li>
          <li><a href="#">test 4</a></li>
          <li><a href="#">test 5</a></li>
          <li><a href="#">test 6</a></li>
          <li><a href="#">test 7</a></li>
          <li><a href="#">test 8</a></li>
          <li><a href="#">test 9</a></li>
        </ul>
     </div>
     <div class="button"></div>
</nav>

#fixedNav {
    position: fixed;
    left: 0;
    top: 70%;
    z-index: 1000;
}
#fixedNav div {
    float: left;
}
#fixedNav .anchors {
    padding: 1em 1em;
    border: 1px solid #ddd;
    border-left: 0;
    overflow-y: scroll;
}
#fixedNav .button {
    width: 50px;
    height: 50px;
    border: 1px solid #ddd;
    border-left: 0;
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

https://jsfiddle.net/850bfnb1/

现在我想添加一个滚动条,因为不是所有的链接都是可见的,因为这个侧边栏的位置,但是它不起作用。滚动条出现但没有效果:(

【问题讨论】:

    标签: css scroll scrollbar fixed


    【解决方案1】:

    尝试添加

    height: 100%;
    

    #fixedNav .anchors - 现在 Anchors 正在填充其父级。

    bottom: 0;
    

    #fixedNav - 现在您确定您的 fixedNav 位于屏幕底部。然后添加

    #fixedNav {
        position: fixed;
        left: 0;
        top: 70%;
        bottom:0;
        z-index: 1000;
    }
    #fixedNav .anchors {
        padding: 1em 1em;
        border: 1px solid #ddd;
        border-left: 0;
        overflow-y: scroll;
        height: 100%;
    }
    

    https://jsfiddle.net/850bfnb1/5/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-26
      • 1970-01-01
      • 1970-01-01
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多