当前位置 : 主页 > 网页制作 > Bootstarp >

下拉菜单 – 移动设备上的非折叠bootstrap 3下拉菜单

来源:互联网 收集:自由互联 发布时间:2021-06-12
我正在尝试使用twitter引导下拉菜单,以便在使用较小的设备时不会崩溃并保持在同一条线路上.这是目前的样子: 我想将名称(在此示例中为John Smith)与“我的应用程序”文本和切换按钮内
我正在尝试使用twitter引导下拉菜单,以便在使用较小的设备时不会崩溃并保持在同一条线路上.这是目前的样子:

我想将名称(在此示例中为John Smith)与“我的应用程序”文本和切换按钮内联.我将如何实现这一目标?

示例:http://bootply.com/99326

<div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <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="#">My Application</a>
        </div>
        <div>
            <ul class="nav navbar-nav navbar-right navbar-user">
                <li class="dropdown user-dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> John Smith <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="#"><i class="fa fa-user"></i> Profile</a></li>
                        <li><a href="#"><i class="fa fa-envelope"></i> Inbox <span class="badge">7</span></a></li>
                        <li><a href="#"><i class="fa fa-gear"></i> Settings</a></li>
                        <li class="divider"></li>
                        <li><a href="#"><i class="fa fa-power-off"></i> Log Out</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
                <li><a href="#">Item 3</a></li>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
</div>
演示: http://jsbin.com/eNUpufIs/2/edit?html,css,output

我使演示链接变大,你可以看到它.

<div class="navbar navbar-default navbar-fixed-top my-custom-nav" role="navigation">

  <div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <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="#">My Application</a>



<div class="navbar-right navbar-text cursor" data-toggle="dropdown" data-target=".user-dropdown">
<i class="fa fa-user"></i> John Smith<b class="caret"></b>
</div>         



       <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
                <li><a href="#">Item 3</a></li>
            </ul>
      </div>



    <ul class="nav navbar-nav navbar-user navbar-right">
                <li class="dropdown user-dropdown">

                    <ul class="dropdown-menu">
                        <li><a href="#"><i class="fa fa-user"></i> Profile</a></li>
                        <li><a href="#"><i class="fa fa-envelope"></i> Inbox<span class="badge">7</span></a></li>
                        <li><a href="#"><i class="fa fa-gear"></i> Settings</a></li>
                        <li class="divider"></li>
                        <li><a href="#"><i class="fa fa-power-off"></i> Log Out</a></li>
                    </ul>
                </li>
            </ul>


</div>
</div>

CSS:

body {padding-top:50px;}

.cursor {cursor:pointer}



/* your going to need to fiddle with the css to make the menu consistent left padding-margin */

/* consistent left padding */
 @media (max-width:767px) {
    .my-custom-nav .navbar-collapse .navbar-nav > li {padding-left:15px!important;}

    .my-custom-nav .user-dropdown > .dropdown-menu > li {padding-left:5px!important;}

}

一定要测试一下!

网友评论