溢出y不会让滚动

时间:2017-01-16 03:23:49

标签: html css scroll sass

这是我的sass代码:

移动导航栏上的滚动条显示但我无法滚动,即使我将高度设置为100%,如果我将高度设置为某些像素,那么滚动让我下降,如果我使用百分比,它不会让我......我不知道为什么,第一次遇到这种问题。

#topnav {
    position: fixed;
    height: 100%;
    left: 0;
    top: 0;
    background-color: darken($default-header-bg, 10);
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;

    width: $mobile-nav-width;

    @include transform(translateX($mobile-nav-width * -1));
    ul {
      li {
        a {
          display: block;
          height: 40px;
          padding: 5px;

          text-align: center;
          line-height: 40px;

          border-bottom: 1px solid $default-header-bg;
        }
      }
    }
  }

2 个答案:

答案 0 :(得分:0)

你需要身高:HTML标签上的100%

html,body {    
  height:100%;
  margin: 0;
}

请参阅scroll bar on div with overflow:auto and percentage height

答案 1 :(得分:0)

通过在侧栏在JS上打开事件时添加以下内容来修复它:

 $('body').css('height', $(window).height());