简体   繁体   English

如何从Bootstrap获取移动下拉菜单?

[英]How can I get the mobile dropdown menu from Bootstrap?

If you go to bootstrap's main website on your phone, you'll notice a slide down menu on the top right. 如果您通过手机访问bootstrap的主要网站,则会在右上角看到一个下拉菜单。

This is part of the nav bar. 这是导航栏的一部分。

Where can I find this dropdown menu plugin? 在哪里可以找到此下拉菜单插件? It's not on the main site. 它不在主站点上。

It's the Responsive Navbar - the variation that shows on mobiles. 这是响应式导航栏-在手机上显示的变体。 To find it and see its usage, read Carlo's comment or go here: 要找到它并查看其用法,请阅读Carlo的评论或转到此处:

http://getbootstrap.com/components/#navbar-default http://getbootstrap.com/components/#navbar-default

See this example: http://twitter.github.com/bootstrap/examples/fluid.html 参见以下示例: http : //twitter.github.com/bootstrap/examples/fluid.html

Remember to add: 请记住添加:

<script src="../assets/js/bootstrap-dropdown.js"></script>

And the css: 和CSS:

<link href="../assets/css/bootstrap.css" rel="stylesheet">
<link href="../assets/css/bootstrap-responsive.css" rel="stylesheet">

This is code sample: 这是代码示例:

<div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="#">Project name</a>
          <div class="nav-collapse collapse">
            <p class="navbar-text pull-right">
              Logged in as <a href="#" class="navbar-link">Username</a>
            </p>
            <ul class="nav">
              <li class="active"><a href="#">Home</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

I believe it is a result of the responsive css bootstrap-responsive.css 我相信这是响应式CSS bootstrap-responsive.css sensitive.css的结果

It shows different on the mobile due to the device width detection. 由于设备宽度检测,它在移动设备上显示不同。

IF you want to download specifically the responsive navbar component , you can do so by goin on to the Customize BootStrap and then select the navbar,navs,tabs and pills and then in responsive section You can select the responsive navbar option and other media components as per your requirement . 如果要专门下载响应式导航栏组件,则可以通过转到“ 自定义引导程序” ,然后选择导航栏,导航,选项卡和药丸,然后在“响应式”部分中进行选择,来选择响应式导航栏选项和其他媒体组件。根据您的要求。 Also you will find Select jquery Plugins section , where you will have to download the following plugins in order to make navbar work as intended :- Affix , Dropdowns,collapse 此外,您还将在“选择jquery插件”部分中找到,您必须在该部分中下载以下插件,以使navbar可以按预期工作:-词缀,下拉列表,折叠

I know this is old now but I found myself working through the same problems and want to provide a barebone example for anyone else who finds it. 我知道这已经很老了,但我发现自己也遇到了同样的问题,并希望为发现它的其他人提供一个准系统的例子。 It is based on Bootstrap 3 though. 它基于Bootstrap 3。

<nav class="navbar container" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main_nav_container" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span> <!-- this are literally the "burger lines" and can be styled -->
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>      

    <!-- Note the ID here is the data-target of the button!! Critically important-->
    <div id="main_nav_container" class="collapse navbar-collapse">
        <ul class="nav navbar-nav">
            <li>your menu item here</li>
        </ul>
    </div>
</nav>

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

相关问题 如何使用JavaScript中的classList.contains在引导程序下拉菜单中获取li类 - how can I get the li classes inside the bootstrap dropdown menu using the classList.contains from javascript 如何从Bootstrap 4的下拉菜单中获取价值? - How to get value from dropdown menu in bootstrap 4? 如何为移动屏幕的导航栏项目添加切换按钮,并使用 HTML、CSS 和 Bootstrap v4 将它们切换为下拉菜单 - How can I add toggle buttons for navbar items for mobile screen and toggle them for dropdown menu using HTML, CSS and Bootstrap v4 如何加速Bootstrap导航栏中的移动下拉列表? - How can I speed up the mobile dropdown in the Bootstrap navbar? 如何从引导程序的下拉菜单中获取两个值 - How to get both values from dropdown menu of bootstrap 如何从引导下拉菜单(jQuery)获取值 - How to get an value from a bootstrap dropdown menu (jQuery) 如何使用 Bootstrap 4 更改下拉菜单活动背景颜色? - How can I change dropdown menu active background color with Bootstrap 4? 如何在Bootstrap 3菜单上删除插入符并在悬停时显示下拉列表? - How can I remove caret on Bootstrap 3 menu and show dropdown on hover? JQuery从bootstrap下拉菜单中获取价值 - JQuery to get value from bootstrap dropdown menu 如何使Bootstrap下拉菜单始终像移动版本一样工作? - How to make Bootstrap dropdown menu always function like mobile version?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM