CSDN博客

img s740556472

bootstrap导航条的二级菜单下实现三级菜单

发表于2017/1/20 17:50:52  5021人阅读

分类: bootstrap

bootstrap在导航条中的二级菜单下实现三级菜单

直接上代码

<!--html里的写法,直接搭好bootstrap导航条结构
    这里就用美食来做例子吧-->



        <!--反色的导航条-->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-
                    toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                                    <span class="sr-only">Toggle navigation</span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                </button>
                    <a class="navbar-brand" href="#">
                                    美食之家  <span class="glyphicon glyphicon-cutlery"></span>
                                </a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li><a href="#">首页</a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">菜谱 
                            <span class="caret"></span></a>
                            <ul class="dropdown-menu" role="menu">
                                <li class="dropdown-submenu">  
                                    <a href="#">主食</a>
                                    <ul class="dropdown-menu">  
                                        <li><a href="#"></a></li>  
                                        <li><a href="#"></a></li>  
                                        <li><a href="#">包子</a></li>
                                    </ul>  
                                </li>
                                <li><a href="#">肉类</a></li>
                                <li><a href="#">水产</a></li>
                            </ul>
                        </li>
                        <li><a href="#">食材</a></li>
                        <li><a href="#">健康</a></li>
                        <li><a href="#">话题</a></li>
                        <li><a href="#">活动</a></li>
                    </ul>
</nav>
<!--CSS样式-->

        <style>
            body {
                padding-top: 70px;
            }



            /*自定义的css*/
            .dropdown-submenu {
                position: relative;
            }

            .dropdown-submenu>.dropdown-menu {
                top: 0;
                left: 100%;
                margin-top: -6px;
                margin-left: -1px;
                -webkit-border-radius: 0 6px 6px 6px;
                -moz-border-radius: 0 6px 6px;
                border-radius: 0 6px 6px 6px;
            }

            .dropdown-submenu:hover>.dropdown-menu {
                display: block;
            }

            .dropdown-submenu>a:after {
                display: block;
                content: " ";
                float: right;
                width: 0;
                height: 0;
                border-color: transparent;
                border-style: solid;
                border-width: 5px 0 5px 5px;
                border-left-color: #ccc;
                margin-top: 5px;
                margin-right: -10px;
            }

            .dropdown-submenu:hover>a:after {
                border-left-color: #fff;
            }

            .dropdown-submenu.pull-left {
                float: none;
            }

            .dropdown-submenu.pull-left>.dropdown-menu {
                left: -100%;
                margin-left: 10px;
                -webkit-border-radius: 6px 0 6px 6px;
                -moz-border-radius: 6px 0 6px 6px;
                border-radius: 6px 0 6px 6px;
            }
        </style>
3 0

相关博文

我的热门文章

img
取 消
img