HTML – 如何使Foundation 5离开画布的导航菜单变粘?

前端之家收集整理的这篇文章主要介绍了HTML – 如何使Foundation 5离开画布的导航菜单变粘?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用最新版本的Foundation来添加一个非画布导航菜单,并在标签栏中添加一个切换.虽然我使用Tab键栏是粘性的,但非画布菜单内容页面滚动.如何使菜单内容变得粘稠,以便在任何尺寸的屏幕或页面上垂直滚动位置按菜单切换将显示菜单内容而不滚动?到目前为止我的 HTML是:
  1. <!doctype html>
  2. <html class="no-js" lang="en">
  3. <head>
  4. <Meta charset="utf-8" />
  5. <Meta name="viewport" content="width=device-width,initial-scale=1.0" />
  6. <title>Foundation | Welcome</title>
  7. <link rel="stylesheet" href="css/foundation.css" />
  8. <script src="js/vendor/modernizr.js"></script>
  9. </head>
  10. <body>
  11. <div class="off-canvas-wrap" data-offcanvas>
  12. <div class="contain-to-grid sticky">
  13. <nav class="tab-bar top-bar" data-topbar data-options="sticky_on: large">
  14. <section class="left-small">
  15. <a class="left-off-canvas-toggle menu-icon" href="#"><span></span></a>
  16. </section>
  17.  
  18. <section class="middle tab-bar-section">
  19. <h1 class="title">Foundation</h1>
  20. </section>
  21. </nav>
  22. </div>
  23.  
  24. <div class="inner-wrap">
  25.  
  26. <!-- Off Canvas Menu -->
  27. <aside class="left-off-canvas-menu">
  28. <!-- whatever you want goes here -->
  29. <ul>
  30. <li><a href="#">Item 1</a></li>
  31. <li><a href="#">Item 2</a></li>
  32. <li><a href="#">Item 3</a></li>
  33. <li><a href="#">Item 4</a></li>
  34. <li><a href="#">Item 5</a></li>
  35. </ul>
  36. </aside>
  37.  
  38. <div class="row">
  39. <div class="large-12 columns">
  40. <h1>Welcome to Foundation</h1>
  41. </div>
  42. </div>
  43.  
  44. <!-- Content goes here -->
  45.  
  46. <!-- close the off-canvas menu -->
  47. <a class="exit-off-canvas"></a>
  48.  
  49. </div>
  50. </div>
  51.  
  52. <script src="js/vendor/jquery.js"></script>
  53. <script src="js/foundation.min.js"></script>
  54. <script>
  55. $(document).foundation();
  56. </script>
  57. </body>
  58. </html>

解决方法

使内容的高度为95vh,溢出-y =滚动.每当滚动右侧的内容时,非画布菜单不受影响并保持在顶部.

CSS:

  1. .mycontent {
  2. height:95vh;
  3. overflow-y:scroll;
  4. /* fix scrolling on webkit touch devices (iPhone etc) */
  5. -webkit-overflow-scrolling: touch;
  6. }

HTML:

  1. <div class="row mycontent" >
  2. <div class="large-12 columns">
  3. <h1>Welcome to Foundation</h1>
  4. </div>
  5. </div>

猜你在找的HTML相关文章