如何使用Bootstrap 4和Angular 7在Navbar中制作多级下拉菜单 [英] How to make multilevel Drop-down menu in Navbar using Bootstrap 4 and Angular 7

查看:44
本文介绍了如何使用Bootstrap 4和Angular 7在Navbar中制作多级下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 bootstrap 4 angular 7 创建多级dropwwon.

我可以使用bootstrap的官方文档在navbar中创建简单的下拉列表.

但是当我尝试创建多级下拉菜单时,它将无法正常工作.

我需要类似这样的结果

解决方案

尝试一下:

 < link href ="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel ="stylesheet" id ="bootstrap-css">< script src ="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"</script>< script src ="//code.jquery.com/jquery-1.11.1.min.js"></script>< div class ="container">< div class ="row">< h2> Bootstrap 3</h2>中的多级下拉菜单.< hr>< div class ="dropdown">< a id ="dLabel" role ="button" data-toggle ="dropdown" class ="btn btn-primary" data-target =#" href ="/page.html">下拉< span class ="caret"></span></a>< ul class ="dropdown-menu multi-level" role ="menu" aria-labelledby ="dropdownMenu">< li>< a href =#">某些动作</a></li>< li>< a href =#">其他动作</a></li>< li class ="divider"></li>< li class ="dropdown-submenu">< a tabindex =-1" href =#">将我悬停以获取更多选项</a>< ul class ="dropdown-menu">< li>< tabindex =-1" href =#">第二级</a></li>< li class ="dropdown-submenu">< a href =#">甚至更多..</a>< ul class ="dropdown-menu">< li>< a href =#">第三级</a></li>< li>< a href =#">第三级</a></li></ul></li>< li>< a href =#">第二级</a></li>< li>< a href =#">第二级</a></li></ul></li></ul></div></div></div> 

请参阅参考资料: https://bootsnipp.com/snippets/kM4Q

I want to create multilevel dropdwon using bootstrap 4 and angular 7.

I could create simple dropdown in navbar using the official documentation of bootstrap.

But when i tried to create multilevel dropdown, it wont working.

Bootstrap 4: Multilevel Dropdown Inside Navigation

using the above link , I could find a solution to make multilevel dropdown.

But it uses some kind of jQuery code for working fine.

Is there any built in method for making multilevel dropdown using bootstrap?

I didn't see anything related to this in official documentation of bootstrap .

I don't know whether I missed any scripts or css in my code.

"styles": [
                            "node_modules/bootstrap/dist/css/bootstrap.min.css",
                            "src/styles.css"

                        ],
                        "scripts": [
                            "node_modules/jquery/dist/jquery.min.js",
                            "node_modules/bootstrap/dist/js/bootstrap.min.js",
                            "node_modules/popper.js/dist/popper.min.js"
                        ],


here is my angular.json part for bootstrap css and js.

any kind of Solution will be thankful.

I need the result something like this

解决方案

Try with this:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>

<div class="container">
    <div class="row">
        <h2>Multi level dropdown menu in Bootstrap 3</h2>
        <hr>
        <div class="dropdown">
            <a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="#" href="/page.html">
                Dropdown <span class="caret"></span>
            </a>
            <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
              <li><a href="#">Some action</a></li>
              <li><a href="#">Some other action</a></li>
              <li class="divider"></li>
              <li class="dropdown-submenu">
                <a tabindex="-1" href="#">Hover me for more options</a>
                <ul class="dropdown-menu">
                  <li><a tabindex="-1" href="#">Second level</a></li>
                  <li class="dropdown-submenu">
                    <a href="#">Even More..</a>
                    <ul class="dropdown-menu">
                        <li><a href="#">3rd level</a></li>
                        <li><a href="#">3rd level</a></li>
                    </ul>
                  </li>
                  <li><a href="#">Second level</a></li>
                  <li><a href="#">Second level</a></li>
                </ul>
              </li>
            </ul>
        </div>
    </div>
</div>

See Reference: https://bootsnipp.com/snippets/kM4Q

这篇关于如何使用Bootstrap 4和Angular 7在Navbar中制作多级下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆