简体   繁体   English

bootstrap折叠导航在我的wordpress主题中不起作用

[英]bootstrap collapse navigation not working in my wordpress theme in mobile

bootstrap collapse navigation not working in my wordpress theme in mobile when i use it on mobile/iphone the menus hide behind the used image-icon but when I clicked on this image it does not collapse and not show the all list item. 当我在手机/ iphone上使用时,bootstrap折叠导航在我的wordpress主题中不起作用,菜单隐藏在使用的图像图标后面,但是当我单击此图像时,它不会折叠并且不会显示所有列表项。

   <div class="container">
<div style="position: static;" class="navbar navbar-inverse">
          <div class="navbar-inner">
            <div class="container">
              <a data-target="navbar-inverse-collapse" data-toggle="collapse" class="btn btn-navbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </a>
              <a href="#" class="brand"><img src="<?php echo get_template_directory_uri();?>/images/spa_logo.png" alt="spasalon" /></a>
               <div class="nav-collapse collapse navbar-inverse-collapse">

                  <?php
          if ( has_nav_menu( 'header-menu' ) ):

          wp_nav_menu( array(  'menu'       => 'header-menu',
                       'theme_location' => 'header-menu',
                       'depth'      => 3,
                       'container'  => false,
                       'menu_class' => 'nav',
                       'menu_id'=>'a',
                       'show_home'=>'HOME',
                      'fallback_cb' => 'wp_page_menu', 

                        'walker' => new twitter_bootstrap_nav_walker()
                        )
                        );


      endif; ?> 


     </div><!-- /.nav-collapse -->
            </div>
          </div><!-- /navbar-inner -->
        </div>

I would try adding bootstrap-collapse.js as an individual file to wp_register_script() in your function file. 我会尝试将bootstrap-collapse.js作为单个文件添加到功能文件中的wp_register_script()。 And make sure you are adding bootstrap.min.js as well properly. 并确保您正确添加了bootstrap.min.js。 I had this same issue and then properly enqueued my js files and then it is now working just fine. 我遇到了同样的问题,然后正确地将我的js文件放入队列,然后它现在可以正常工作了。

I found the solution while creating theme for my blog . 我在为博客创建主题时找到了解决方案。

Script to be added... 要添加的脚本...

<script src="js/bootstrap.min.js"></script>
  • Please go to functions.php file into themes folder and ADD below function. 请转到functions.php文件进入主题文件夹,然后在函数下方添加。

     function tsbs2013_scripts_with_jquery(){ // Register the script like this for a theme: wp_register_script( 'custom-script', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ) ); // For either a plugin or a theme, you can then enqueue the script: wp_enqueue_script( 'custom-script' ); } add_action( 'wp_enqueue_scripts', 'tsbs2013_scripts_with_jquery' ); 

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

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