基金会6菜单图标已在点击链接上显示

时间:2016-03-25 14:51:26

标签: html ruby-on-rails ruby-on-rails-4 sass zurb-foundation

我在Rails 4上使用基础6和scss这个顶级菜单。 问题是,只要你点击菜单图标(汉堡包)菜单中的任何链接,它就不应该因为是全屏,它也会停止响应汉堡包图标中的onclick事件。这是一个错误还是我做错了什么?

               <div class="top-bar">
            <div class="top-bar-title">
                <div>
                   <%= link_to image_tag("logo.png", alt: "PeopleWare SRL"), page_path('index') %>
                </div>            
              <span data-responsive-toggle="responsive-menu" data-hide-for="medium">
                <button class="menu-icon dark" type="button" data-toggle></button>
              </span>
            </div>
            <div id="responsive-menu">
              <div class="top-bar-right">
                 <ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown">
                    <li><%= link_to 'Blog', page_path('blog') %></li>
                    <li><%= link_to "Support", "http://soporte.peopleware.do" %></li>
                 </ul>
              </div>
               </div>
        </div>

您可以在此处测试菜单:http://carey.peopleware.do

2 个答案:

答案 0 :(得分:1)

从版本6开始的基础响应式菜单将标题栏与顶栏分开,您的标记不会反映该更新。为了使响应式菜单起作用,标记树中的切换需要更高。 Responsive Toggle

编译标记的第28-56行是:

 <section id="menu" class="menu">
     <div class="row">
    <div class="medium-12 columns">
           <div class="top-bar">
            <div class="top-bar-title">
              <span data-responsive-toggle="responsive-menu" data-hide-for="medium">
                <button class="menu-icon dark" type="button" data-toggle></button>
              </span>
                <div>
                   <a href="/index"><img alt="PeopleWare SRL" src="/assets/logo-345d236755fdd29efe4113717b59043034744758f71f11618e58672f2e0dbc6b.png" /></a>
                </div>            
            </div>
            <div id="responsive-menu">
              <div class="top-bar-right">
                 <ul class="vertical medium-horizontal menu">
                    <!--<li><a href="/blog">Blog</a></li> -->
                <li><a href="/index#services">Services</a></li>
                <li><a href="/jason">Software</a></li>
                    <li><a href="/about">About us</a></li>
                <li><a href="/index#careers">Careers</a></li>
                    <li><a href="/index#contact">Contact us</a></li>
                <!--<li><a href="http://soporte.peopleware.do">Support</a></li>-->
                 </ul>
              </div>
               </div>
        </div>
    </div>
     </div>
  </section>

需要从顶栏中删除top-bar-title div并重命名为title-bar-title(感谢Zurb命名的东西)。这个div需要在div级别的标题栏中。此外,标题栏标题不应包含按钮或png图像。

所以这个:

<div class="top-bar">
  <div class="top-bar-title">
    <span data-responsive-toggle="responsive-menu" data-hide-for="medium">
      <button class="menu-icon dark" type="button" data-toggle></button>
    </span>
    <div>
      <a href="/index"><img alt="PeopleWare SRL" src="/assets/logo-345d236755fdd29efe4113717b59043034744758f71f11618e58672f2e0dbc6b.png" /></a>
    </div>            
  </div>
  <div id="responsive-menu">

会变成:

<div class="title-bar" data-responsive-toggle="responsive-menu" data-hide-for="medium">
    <button class="menu-icon dark" type="button" data-toggle></button>
  <div class="title-bar-title">PeopleWare</div>
</div>

<div class="top-bar" id="responsive-menu">
  <div>
    <a href="/index"><img alt="PeopleWare SRL" src="/assets/logo-345d236755fdd29efe4113717b59043034744758f71f11618e58672f2e0dbc6b.png" /></a>
  </div>

除非您确实尝试在响应式菜单上获取图像。

无论如何,我使用控制台解决了其他问题:

$(document).foundation()

使用Zurb,您需要告诉javascript执行。一旦运行,我可以切换菜单。你可能需要在某个地方使用coffeeScript

$ ->
  $(document).foundation()

这将等到dom准备好并运行基础。

答案 1 :(得分:0)

我有同样的问题。我只是设置CSS规则:

@media only screen and (min-width: 641px) {
    .title-bar {
        display: none;
    }
}