3

对于一个大学项目,我正在尝试为响应式网站实施移动菜单。为此,我使用了 jQuery 插件 mmenu。

一切似乎都很好,除了一件事:每当我打开菜单时,它都会滚动到页面顶部,而不是停留在原来的位置。我还意识到在菜单打开时我无法滚动页面(与此处的示例相反:http: //mmenu.frebsite.nl/mmenu/demo/onepage.html

我的代码结构如下:

<body>
    <!-- Mobile Navigation -->
    <nav id="mobilenav">
        <div>
            <ul>
                ... 
            </ul>
        </div>
    </nav>
    <div id="wrapper">
        <header class="mm-fixed-top hidden-desktop">
            ...
            <a href="#mobilenav" class="pull-left"><i class="fa fa-bars"></i></a>
            ...
        </header>
        <div id="topbar">
            ...
        </div>
        <div id="content">
            ...
        </div>
    </div>
    <div id="tothetop" class="hidden-desktop">
        ...
    </div>
    <div id="bottom" class="visible-desktop">
        ...
    </div>
    <!-- Scripts -->
        ...
</body>

您可以在http://www.mikehudson.de/BA/上查看实际问题。

提前感谢您的回答。

——迈克

4

2 回答 2

5

您是否将此插件与 Foundation 5 一起使用。如果是这样,那么您可以在 global.scss 文件中将 html、body 高度从 100% 更改为 auto。

例如...

从:

// Must be 100% for off canvas to work


    html, body { height: 100%; }

至:

// Must be 100% for off canvas to work


     html, body { height: auto; }
于 2014-09-18T06:02:51.080 回答
3

如果您确实将 100% 应用于 body/html,如果您的触发器在 href 中碰巧有一个“#”,请确保在 click 事件上使用 preventDefault()。这让我绊倒了。

于 2015-02-12T06:23:48.373 回答