Drop-Down Menu not working on mobile devices

前端 未结 7 1676
广开言路
广开言路 2020-12-29 08:40

The most recent version of twitter bootstrap (2.3.2) does seem to have a problem with drop down menus on mobile devices.

When you click on a drop-down menu item afte

相关标签:
7条回答
  • 2020-12-29 08:47

    For me, it worked adding to my styles:

    .dropdown-backdrop {
        z-index:0;
    }
    

    almost the same answer as Matthias, i hope it helps.

    0 讨论(0)
  • 2020-12-29 08:47

    None of the usual answers seemed to fix our problem on Android. We tried the accepted answer here and a few javascript hacks as well: Bootstrap Collapsed Menu Links Not Working on Mobile Devices and http://alittlecode.com/fix-twitter-bootstraps-dropdown-menus-in-touch-screens/

    Ultimately we discovered where the close was occurring and conditionally called clearMenus() only if the links parent or grand parent did not have dropdown-submenu class

    $(document)
    .on('click.dropdown.data-api', function (e) {
    
        //fix start        
        var $parent = $(e.target).parent()
        var $grandparent = $parent.parent()
    
        if (!$parent.hasClass('dropdown-submenu') && !$grandparent.hasClass('dropdown-submenu')) {        
            clearMenus()
        }
    
        //clearMenus
    
        //end fix
    })
    .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
    .on('click.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
    .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
    
    }(window.jQuery);
    

    Hope that helps!

    0 讨论(0)
  • 2020-12-29 08:58

    Try this. It's work for me

     @media only screen and (max-width: 768px) {
        .dropdown-menu {
            position: absolute;
        }
     }
    
    0 讨论(0)
  • 2020-12-29 08:59
    $('.dropdown a').click(function(e) {
          e.preventDefault();
          setTimeout($.proxy(function() {
            if ('ontouchstart' in document.documentElement) {
              $(this).siblings('.dropdown-backdrop ').off().remove();
            }
          }, this), 0);
    
        }); 
    
    0 讨论(0)
  • 2020-12-29 09:00

    A temporary fix is to add

    .dropdown-backdrop{
        position: static;
    }
    

    to the css file.

    0 讨论(0)
  • 2020-12-29 09:01

    I have fixed this issue.

    My code is here

       <li class="dropdown custom open"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> menu<b class="caret"></b></a>
                 <ul class="dropdown-menu">
                     <li><a href="#">Sub menu</a></li>
                     <li><a href="#">Sub menu2</a></li>
                  </ul>
               </li>
    

    Add following style in your CSS fie.

    @media (max-width: 767px) { 
    .dropdown.custom:hover .dropdown-menu {
      visibility: visible;
      display:block;
      border-radius:0;
    
    }
    }
    

    Visit: http://www.s4auto.co.za/

    0 讨论(0)
提交回复
热议问题