javascript - 如何使我的 Canvas 外菜单滚动?

标签 javascript jquery html css mobile

我一直在尝试通过滚动来使我的非 Canvas 菜单正常工作,尤其是在横向模式下,因为列表本身的运行时间超过了屏幕的大小。对于平板电脑和移动设备,此菜单显示在 768 像素下方。

澄清一下,菜单项比屏幕空间长,我试图通过多种方法让它滚动,例如 overflow-y: scroll, -webkit-overflow-scrolling: touch 等等(当我在检查器中搞砸时,所有这些都可以在手机大小的桌面浏览器中使用)。

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

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;
  }

实时链接:http://bit.ly/1eGCShX

最佳答案

cbp-spmenu最小高度为 550 像素。这就是限制您以较小的分辨率滚动它的能力的原因。

删除最小高度,你应该没问题。当然,作为媒体查询来做,所以它只对移动设备有效。

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

不确定你是否刚刚更改了它,但我又看了一下,现在我没有看到 min-height,而是添加了 overflow:auto cbp-spmenu 元素也使它滚动。

关于javascript - 如何使我的 Canvas 外菜单滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22264526/

相关文章:

javascript - 在 html 页面之间移动

javascript - 将鼠标悬停在热点上时带有图像弹出窗口的图像映射

html - 独立于段落的文字说明文本设置

php - 在 php 数组中获取 HTML 表格数据

javascript - 如何将变量传递给 JavaScript 函数内的方法

javascript - jQuery 动态更新数据键和值

javascript - 在选择中对齐文本中心

javascript - 有 100 行的表;需要根据行中单击的链接显示一个 div

javascript - 抵消 bootstrap/select2 渲染延迟?

jquery - 网页动画css高亮