简体   繁体   English

响应式导航栏使用基础的顶级课程

[英]Responsive nav bar using foundation's top-bar class

Troubles toggling the hamburger menu and large size menus based on screen sizes, using zurb-foundation top-bar framework.I get both top-bars one below the other, regardless of screen size. 麻烦根据屏幕尺寸切换汉堡包菜单和大尺寸菜单,使用zurb-foundation顶栏框架。无论屏幕大小如何,我都可以将两个顶部栏一个放在另一个之下。

I have tried rearranging the order in which i load the java script files for foundation, but no luck. 我已经尝试重新排列我加载基础的java脚本文件的顺序,但没有运气。 I have read over the docs a million times and just cannot find the problem. 我已经阅读了一百万次的文档而且找不到问题。 I even commented out my entire top-bar and copied and pasted the one from the foundation site and it did the same thing. 我甚至评论了我的整个顶栏,并从基础网站复制并粘贴了一个,它做了同样的事情。

What I think might be the issue: -since a similar thing happens with the exact code from the zurb-foundation docs, I'm wondering if it is the order I am en-queuing my scripts in my functions.php file for WordPress, some fresh eyes would be appreciated. 我认为可能是这个问题: - 由于类似的事情发生在zurb-foundation文档的确切代码中,我想知道这是否是我在我的functions.php文件中为WordPress启用我的脚本的顺序,一些新鲜的眼睛将不胜感激。

<div class="title-bar" data-responsive-toggle="responsive_menu" data-hide- 
    for="large">
    <button class="menu-icon" type="button" data-toggle></button>
    <div class="title-bar-title"></div>
</div>


<div class="top-bar" id="responsive_menu">
    <div class="top-bar-left">
        <ul class="medium-horizontal menu">
            <li class="menu-text">Save on Experiences</li>
        </ul>
    </div>
    <div class="top-bar-right">
        <ul class="medium-horizontal menu">
            <li><a href="#">Featured Discounts</a></li>
            <li><a href="#">Experiences</a></li>
            <li><a href="#">Reviews</a></li>
            <li><a href="#">About Us</a></li>
            <li><a href="#">Support</a></li>
            <li><a href="#">News</a></li>
        </ul>
    </div>

</div>

snipping from functions.php 从functions.php剪断

wp_enqueue_style('layout', get_template_directory_uri() . '/assets/css/foundation.min.css'); wp_enqueue_style('layout',get_template_directory_uri()。'/ assets / css / foundation.min.css'); wp_enqueue_script('foundation-script-min', get_template_directory_uri() . '/assets/js/vendor/foundation.min.js', '', '', true); wp_enqueue_script('foundation-script-min',get_template_directory_uri()。'/ assets / js / vendor / foundation.min.js','','',true); wp_enqueue_script('foundation-script-jquery', get_template_directory_uri() . '/assets/js/vendor/jquery.js', '', '', true); wp_enqueue_script('foundation-script-jquery',get_template_directory_uri()。'/ assets / js / vendor / jquery.js','','',true); wp_enqueue_script('foundation-script-whatinput', get_template_directory_uri() . '/assets/js/vendor/what-input.js', '', '', true); wp_enqueue_script('foundation-script-whatinput',get_template_directory_uri()。'/ assets / js / vendor / what-input.js','','',true);

Functionality I want: 我想要的功能:

  • on small screens user views a hamburger menu only 在小屏幕上,用户只能看到汉堡包菜单
  • on medium and up size screens the user does not see hamburger menu and has a proper size top-bar 在中型和大型屏幕上,用户看不到汉堡包菜单并且具有适当尺寸的顶栏

Functionality thus far: 到目前为止的功能:

  • the toggle feature between the full size and hamburger size menu is not working 全尺寸和汉堡包尺寸菜单之间的切换功能不起作用
  • I get both top-bars one below the other, regardless of screen size 无论屏幕尺寸如何,我都会将两个顶杆都放在另一个之下

for foundation version 6.5.3 you can use class to hide/show based on screen size, (show-for-medium, show-for-small-only). 对于基础版本6.5.3,您可以根据屏幕大小使用类来隐藏/显示(show-for-medium,show-for-small-only)。 your markup can be changed like this 您的标记可以像这样更改

<div class="title-bar show-for-small-only" data-responsive-toggle="responsive_menu" data-hide- 
    for="large">
    <button class="menu-icon" type="button" data-toggle></button>
    <div class="title-bar-title"></div>

<div class="top-bar show-for-medium" id="responsive_menu">
    <div class="top-bar-left">
        <ul class="medium-horizontal menu">
            <li class="menu-text">Save on Experiences</li>
        </ul>
    </div>
    <div class="top-bar-right">
        <ul class="medium-horizontal menu">
            <li><a href="#">Featured Discounts</a></li>
            <li><a href="#">Experiences</a></li>
            <li><a href="#">Reviews</a></li>
            <li><a href="#">About Us</a></li>
            <li><a href="#">Support</a></li>
            <li><a href="#">News</a></li>
        </ul>
    </div>

</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM