asp.net-mvc MVC 中的 Bootstrap 下拉导航
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23363584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 03:39:50 来源:igfitidea点击:
Bootstrap Drop down navigation in MVC
提问by rikket
I have the following navigation on MVCusing bootstrap, how can I make the Storage Menu Link (second li) as a drowndown to include Add and View Links without removing the @ActionLink?
我有以下关于MVC使用引导程序的导航,如何在li不删除@ActionLink?
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="/Home/Home">News Library</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="@ActiveLink("Home", "Home", null)">@Html.ActionLink("Home", "Home", "Home")</li>
<li class="@ActiveLink("About", "Home", null)">@Html.ActionLink("Storage", "Add", "Storage")</li>
<li class="@ActiveLink("Contact", "Home", null)">@Html.ActionLink("Activites", "Add", "Activites")</li>
<li class="@ActiveLink("Contact", "Home", null)">@Html.ActionLink("Search", "Index", "Search")</li>
</ul>
<ul class="nav pull-right">
<li>@Html.ActionLink("[Log Out]", "Logout", "Home")</li>
</ul>
</div>
</div>
</div>
</div>
回答by Electric Sheep
<li class="@ActiveLink("Home", "Home", null) dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Storage
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>@Html.ActionLink("Storage", "Add", "Storage")</li>
<li>@Html.ActionLink("Storage", "View", "Storage")</li>
</ul>
</li>

