如何使我的非画布菜单滚动?

时间:2014-03-08 03:12:56

标签: javascript jquery html css mobile

我一直试图通过在横向模式下滚动来使我的非画布菜单工作,因为列表本身的运行时间长于屏幕的大小。平板电脑和手机的此菜单如下所示:768px。

为了澄清,菜单项比屏幕空间更长,我试图通过多种方法滚动它,例如 overflow-y:scroll,-webkit-overflow-scrolling:touch < / strong>以及更多(当我在检查员中弄乱时,所有这些都在桌面浏览器中以手机大小工作)。

我一直在尝试检查元素并让菜单在需要时滚动而不是背景(网站/页面背后的菜单)。这里有一些我的标记和样式,我还包括一个实时链接来检查它比在这里粘贴所有内容更容易。非常感谢任何帮助!

LIVE LINK

<body class="cbp-spmenu-push">
<nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left mobile" id="cbp-spmenu-s1">
    <a class="m-storyLink mobile-nav-link" href="">1</a>
    <a href="/news" class="m-newsLink mobile-nav-link">2</a>
    <a href="/justmayo" class="m-mayoLink mobile-nav-link">3</a>
    <a href="#" class="mobile m-contactHead show-for-small-only mobile-nav-link">3</a>
    <a href="" class="show-for-medium-only m-contactHead mobile-nav-link fancybox fancybox.iframe" data-fancybox-type="iframe" href="contact-form.php">Contact Us</a>
    <a href="#" class="mobile mobile-nav-link m-phone-num">4</a>
      <ul class="mobile-social">
          <li><a href="//www.facebook.com/" target="_blank" class="mobile-fb"></a></li>
          <li><a href="//twitter.com/" target="_blank" class="mobile-twit"></a></li>
          <li><a href="" class="mobile-goog"></a></li>
      </ul>
</nav>

<header id="header" class="header headroom headroom--pinned">
  <!-- mobile header --> 
  <div class="mobile">
    <button id="showLeftPush">MENU</button>
    <a href="#top" class="mobile-logo mobile"><img src="img/home/logo.png" alt="#"</a>
  </div>

和CSS

.cbp-spmenu-push-toright {
left: 240px!important;
}

.cbp-spmenu-push-toright.cbp-spmenu-push {
overflow: hidden;
position: fixed;
}
/* General styles push menu*/
.cbp-spmenu {
    background-color: #000;
    position: fixed;
   font-family: FranklinGothicLTCom-BkCm, "Arial Narrow", sans-serif;
   padding: 110px 0 0 0;
 }

  .mobile-nav-link {
    background-position: 10px center;
  }


  /* Orientation-dependent styles for the content of the menu */

  .cbp-spmenu-vertical {
    width: 240px;
    min-height: 300px;
    height: 100%;
    top: 0;
    z-index: 1000;
    -webkit-transition: all 250ms ease-in-out;
    -moz-transition: all 250ms ease-in-out;
    -ms-transition: all 250ms ease-in-out;
    -o-transition: all 250ms ease-in-out;
    transition: all 250ms ease-in-out;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
  }


  .cbp-spmenu-left {
    left: -240px;
  }

  .cbp-spmenu-right {
    right: -240px;
  }

  .cbp-spmenu-left.cbp-spmenu-open {
    left: 0px;
  }

  .cbp-spmenu-right.cbp-spmenu-open {
    right: 0px;
  }

  /* Horizontal menu that slides from the top or bottom */

  .cbp-spmenu-top {
    top: -150px;
  }

  .cbp-spmenu-bottom {
    bottom: -150px;
  }

  .cbp-spmenu-top.cbp-spmenu-open {
    top: 0px;
  }

  .cbp-spmenu-bottom.cbp-spmenu-open {
    bottom: 0px;
  }

  /* Push classes applied to the body */

  .cbp-spmenu-push {
    position: relative;
    left: 0;
    -webkit-transition: all 250ms ease-in-out;
    -moz-transition: all 250ms ease-in-out;
    -ms-transition: all 250ms ease-in-out;
    -o-transition: all 250ms ease-in-out;
    transition: all 250ms ease-in-out;
  }

LIVE LINK:http://bit.ly/1eGCShX

1 个答案:

答案 0 :(得分:4)

cbp-spmenu有一个min-height of 550px。这限制了您以较小的分辨率滚动它的能力。

删除最小高度,你应该没事。当然,将其作为媒体查询,因此它仅在移动设备上有效。

-----------更新----------------

不确定您是否刚刚更改了它,但我又看了一眼,现在我看不到min-height,但将overflow:auto添加到同一个cbp-spmenu元素也会让它滚动。