I have a nav-pills menu, and when it collapse it is horizontal. I would like a menu like the navbar when it is collapse. I have search the internet, the only soloution was to make to menus and I don´t think that is the best soloution.
<div class="navbar">
<button type="button" class="navbar-toggle btn btn-navbar-highlight btn-large btn-primary" data-toggle="collapse" data-target=".navbar-collapse">
NAVIGATION <span class="icon-chevron-down icon-white"></span>
</button>
<div class="navbar-collapse collapse" style="background-color:deeppink;">
<ul class="nav navbar ddmenu">
<li class="dropdown active">#Html.ActionLink("Home", "Index", "Home")</li>
<li class="dropdown">
Transport <b class="caret"></b>
<ul class="dropdown-menu">
<li>#Html.ActionLink("Medicin", "Medicin", "Home")</li>
<li>#Html.ActionLink("Køl / Varme / Frost", "Temperaturkontrolleret", "Home")</li>
<li>#Html.ActionLink("ADR", "ADR", "Home")</li>
<li>#Html.ActionLink("Express", "Express", "Home")</li>
<li>#Html.ActionLink("Flytninger", "Flytninger", "Home")</li>
<li>#Html.ActionLink("SLV", "SLV", "Home")</li>
<li>#Html.ActionLink("Dyr", "Dyr", "Home")</li>
<li>#Html.ActionLink("Håndvåben", "Weapons", "Home")</li>
<li>#Html.ActionLink("England Tur/Retur", "TurRetur", "Home")</li>
</ul>
</li>
<li class="dropdown">#Html.ActionLink("Priser", "Priser", "Home")</li>
<li class="dropdown">#Html.ActionLink("Nyheder", "Nyheder", "Home")</li>
<li class="dropdown">#Html.ActionLink("Kontakt", "Kontakt", "Home")</li>
<li class="dropdown">#Html.ActionLink("Job", "Vognmand", "Home")</li>
<li>
<a class="hideButtonDk" href="#Url.Action("Change", "Home", new { Lang = "da"})">
<img src="#Url.Content("~/Images/icon_uk.png")" />
</a>
</li>
</ul>
</div>
</div>
Hope someone could help me with this soloution
I solved it with this one
.nav-pills.ddmenu > li{
width: 100%;
}
and in dropdown menu
.nav-pills > li > .dropdown-menu{
height:auto;
width:98%;
}
Related
I have been trying to get this to work but doesn't seem to work. Basically I need a dynamic navbar. The pre-built .NET template actually has already generated a _LoginPartial.cshtml, which already changes the navbar depending on whether a user is login or not. I have been trying to edit the navbar so that it supports another level of change to check if a user is on a specific page then it will show more or less items depending on whether a boolean (showAll) is set to true or false. However is there a way to set the boolean based on the page? Currently I test it by changing manually and the logic works. I need a dynamic way to control it programmatically. Thank you for your help!
#using Microsoft.AspNetCore.Identity
#inject SignInManager<IdentityUser> SignInManager
#inject UserManager<IdentityUser> UserManager
#{bool showAll = false;}
#if (SignInManager.IsSignedIn(User) && showAll == true)
{
<ul class="nav navbar-nav mr-auto">
<li class="nav-item"><a asp-area="" asp-controller="Home" asp-action="Index" class="nav-link">Home</a></li>
<li class="nav-item"><a asp-area="" asp-controller="Home" asp-action="About" class="nav-link">About</a></li>
<li class="nav-item"><a asp-area="" asp-controller="Home" asp-action="Contact" class="nav-link">Contact</a></li>
</ul>
<form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="#Url.Action("Index", "Home", new { area = "" })" method="post" id="logoutForm" class="navbar-right">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage" class="nav-link">Hello #UserManager.GetUserName(User)!</a>
</li>
<li class="nav-item">
<button type="submit" class="btn btn-link navbar-btn navbar-link">Logout</button>
</li>
</ul>
</form>
}
else if (SignInManager.IsSignedIn(User) && showAll == false)
{
<ul class="nav navbar-nav mr-auto">
<li class="nav-item"><a asp-area="" asp-controller="Home" asp-action="Index" class="nav-link">Home</a></li>
<li class="nav-item"><a asp-area="" asp-controller="Home" asp-action="About" class="nav-link">About</a></li>
</ul>
<form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="#Url.Action("Index", "Home", new { area = "" })" method="post" id="logoutForm" class="navbar-right">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage" class="nav-link">Hello #UserManager.GetUserName(User)!</a>
</li>
<li class="nav-item">
<button type="submit" class="btn btn-link navbar-btn navbar-link">Logout</button>
</li>
</ul>
</form>
}
else
{
<ul class="nav navbar-nav mr-auto">
<li class="nav-item"><a asp-area="" asp-controller="Home" asp-action="Index" class="nav-link">Home</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item"><a asp-area="Identity" asp-page="/Account/Register" class="nav-link">Register</a></li>
<li class="nav-item"><a asp-area="Identity" asp-page="/Account/Login" class="nav-link">Login</a></li>
</ul>
}
It depends a lot on what logic is behind that variable. If you can resolve it just from the login partial, you can certainly just add the logic there. For example, you could look at the current route to figure out whether you want that value to be true or not.
You could also build your own service that you inject there which then contains the logic. This can be useful if you end up doing more complicated stuff, as you should generally try to avoid too much logic inside views.
If the value is being set outside of the partial, you could also just use the ViewData dictionary to set it. This would allow you to set the value within your controllers, and then your partial view could just retrieve the value. Something like this:
#{
bool showAll = false; // default
if (ViewData.TryGetValue("NavigationShowAll", out var value) && value is bool)
{
showAll = (bool)value;
}
}
And then, in your controller, you can just do this:
public IActionResult DoSomething()
{
ViewData["NavigationShowAll"] = true;
return View();
}
I have a login page, but whenever I typed wrong credentials it showing the mainheader for login person but with no name.. See the image I attached for further explanations
login
login with wrrong credentials
this is what it look like when the person login successfully, it have name and company
View form
<ul class="nav navbar-nav navbar-right">
#{
AccountContactVM customer = (AccountContactVM)ViewBag.AccountData;
}
#if (customer.User == customer.User && customer.User != null )
{
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="fa fa-user-circle fa-fw fa-lg" aria-hidden="true"</i>
#customer.User.FirstName #customer.User.LastName
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="disabled">
<div class="row">
<div class="col-md-3">
<i class="fa fa-user-circle" style="font-size:40px;padding:5px 20px;" aria-hidden="true"></i>
</div>
<div class="col-md-9">
<p style="padding-top:5px;">
#customer.User.FirstName #customer.User.LastName
<br />
#customer.Company.AccountName
</p>
</div>
</div>
</li>
<li class="divider"></li>
<li><a asp-controller="Account" asp-action="Index">Customer Portal</a></li>
<li class="divider"></li>
<li><a a asp-controller="Account" asp-action="LogOut">Logout</a></li>
</ul>
</li>
}
else
{
<li><a asp-controller="Account" asp-action="SignUp">Register</a></li>
<li><a asp-controller="Account" asp-action="SignIn"><i class="fa fa-sign-in fa-fw" aria-hidden="true"></i>Login</a></li>
}
<li ng-cloak><span class="glyphicon glyphicon-shopping-cart"></span></i>Cart(<strong>{{CartCount}}</strong>)</li>
</ul>
Below is my code snippet:
<div class="container">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="#">This is a LOGO </a>
</div>
<ul class="nav navbar-nav pull-right">
<li><a href="#" > Abous US </a></li>
<li><a href="#" > Contact US </a></li>
<li><a href="#" > Acount </a></li>
</ul>
</nav>
</div>
</div>
</div>
My question: How can I pull ABOUT US and CONTACT US items into the right and the ACOUNT is in the left?
As per the docs, you can use navbar-right to pull some elements to the right:
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
I am using bootstrap, and the default for mobile navigation is 768px. I want to expand this to 979px instead? I have search and try anything for hours but with no luck at all. Can someone help me with this problem?
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="col-md-4" style="background-color:coral;">
<div id="divLogo" class="pull-left">
<img src="~/Images/logo.png" />
</div>
</div>
<div class="col-lg-8" style="background-color:crimson;">
<div id="divMenuRight">
<div class="navbar">
<button type="button" class="navbar-toggle btn btn-navbar-highlight btn-large btn-primary" data-toggle="collapse" data-target=".navbar-collapse">
NAVIGATION <span class="icon-chevron-down icon-white"></span>
</button>
<div class="navbar-collapse collapse">
<ul class="nav nav-pills ddmenu">
<li class="active">#Html.ActionLink("Home", "Index", "Home")</li>
<li class="dropdown">
Transport <b class="caret"></b>
<ul class="dropdown-menu">
<li>#Html.ActionLink("Medicin", "Medicin", "Home")</li>
<li>#Html.ActionLink("Køl / Varme / Frost", "Temperaturkontrolleret", "Home")</li>
<li>#Html.ActionLink("ADR", "ADR", "Home")</li>
<li>#Html.ActionLink("Express", "Express", "Home")</li>
<li>#Html.ActionLink("Flytninger", "Flytninger", "Home")</li>
<li>#Html.ActionLink("SLV", "SLV", "Home")</li>
<li>#Html.ActionLink("Dyr", "Dyr", "Home")</li>
<li>#Html.ActionLink("Håndvåben", "Weapons", "Home")</li>
<li>#Html.ActionLink("England Tur/Retur", "TurRetur", "Home")</li>
</ul>
</li>
<li>#Html.ActionLink("Priser", "Priser", "Home")</li>
<li>#Html.ActionLink("Nyheder", "Nyheder", "Home")</li>
<li>#Html.ActionLink("Kontakt", "Kontakt", "Home")</li>
<li>#Html.ActionLink("Job", "Vognmand", "Home")</li>
<li>
<a class="hideButtonDk" href="#Url.Action("Change", "Home", new { Lang = "da"})">
<img src="#Url.Content("~/Images/icon_uk.png")" />
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
You will need to download a custom build of bootstrap from their site and update the default in the "Media queries breakpoints" section.
Update the width for the "screen-sm" variable from 768px to the desired value.
http://getbootstrap.com/customize/
I have the following navigation on MVC using bootstrap, how can I make the Storage Menu Link (second li ) as a drowndown to include Add and View Links without removing the #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>
<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>
See the bootstrap site for more information