gpt4 book ai didi

drop-down-menu - 移动设备上的非折叠 Bootstrap 3 下拉菜单

转载 作者:行者123 更新时间:2023-12-04 06:40:27 26 4
gpt4 key购买 nike

我试图让 twitter 引导下拉菜单在使用较小的设备时不折叠并保持在同一行。这是它目前的样子:

enter image description here

我希望名称(在本例中为 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;}

}
确保你测试它!

关于drop-down-menu - 移动设备上的非折叠 Bootstrap 3 下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20463028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com