I am trying to add dropdown submenu to bootstrap menubar, Submenu appears as soon as i hover on the "people aspect".But when submenu appears it is extending the size of menubar. Is there any way the fix the size of the menubar
Here is the code
<div class="navbar navbar-inverse navbar-fixed-top" >
<div class="container" >
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div >
#* #Html.ActionLink("Application name", "Index", "Home", null, new { #class = "navbar-brand" })*#<img src="~/Images/InfosysLogo.png" style="height:70px;width:200px" />
</div>
</div>
<div class="navbar-collapse collapse">
<ul id="nav" class="nav navbar-nav">
<li>#Html.ActionLink("DashBoard", "ExecutiveDashboard", "Charts")</li>
<li>#Html.ActionLink("Engagement Metrics", "EngagementMatrix", "Charts")</li>
<li>#Html.ActionLink("Quality Metrics", "Contact", "Home")</li>
<li>
#Html.ActionLink("People Aspects", "Contact", "Home")
<ul id="subnav">
<li>#Html.ActionLink("Certifications", "Index", "Certification", new { #class = "my-class" })</li>
<li>#Html.ActionLink("Trainings", "Index", "Training", new { #class = "my-class" })</li>
</ul>
</li>
<li>#Html.ActionLink("Financials", "BudgetVSActualChart", "Financial")</li>
<li>#Html.ActionLink("Admin", "AdminView", "PMODashboard")</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="navbar-text">Hello, #User.Identity.Name!</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
Any help will be appreciable.
Thank you
example try this code of css and check
HTML
<div class="navbar navbar-inverse navbar-fixed-top" >
</div>
CSS
.navbar{
width:980px;
}
HTML
<div class="navbar navbar-inverse navbar-fixed-top" >
</div>
CSS
.navbar{
min-height:90px !important;
}
resolved my issue it set the min height to 90px so when i was hovering on menu item submenu items were not extending my menubar
Related
I'm trying to create a layout using jumbotron and navbar but I cannot do it. I want that the jumbotron is located on top and the navbar is under of it. After I created I don't know why it has space on top and between the navbar.
How do I fix this ?
trying
<!-- Header.cshtml to use as a Partial to include on main layout -->
<header class="jumbotron bg-red">
<h1>My first layout</h1>
<h3>Trying to create a layout using jumbotron and navbar</h3>
</header><!--jumbotron-->
<div class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="~/Imagens/logo.png" width="32" height="32" title="Red Cherry" />
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
#Html.Partial("_LoginPartial")
</div>
</div>
</div><!--nav bar-->
Not sure why you having this issue, have you changed anything in the bootstrap css?
For a quick fix you can do some css, add a class 'remove-space' to the header tag.
<header class="jumbotron bg-red remove-space">
Then apply this css to it.
.remove-space{
margin: -50px 0 0 0;
}
I am trying to restrict the width of the submenu items "Certification" and "Training", Currently it is occupying the whole window size.
Here is the code
<div class="navbar navbar-inverse navbar-fixed-top" >
<div class="container" >
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div >
#* #Html.ActionLink("Application name", "Index", "Home", null, new { #class = "navbar-brand" })*#<img src="~/Images/InfosysLogo.png" style="height:70px;width:200px" />
</div>
</div>
<div class="navbar-collapse collapse">
<ul id="nav" class="nav navbar-nav">
<li>#Html.ActionLink("DashBoard", "ExecutiveDashboard", "Charts")</li>
<li>#Html.ActionLink("Engagement Metrics", "EngagementMatrix", "Charts")</li>
<li>#Html.ActionLink("Quality Metrics", "Contact", "Home")</li>
<li>
#Html.ActionLink("People Aspects", "Contact", "Home")
<ul>
<li>#Html.ActionLink("Certifications", "Index", "Certification",null, new { #class = "my-class" })</li>
<li>#Html.ActionLink("Trainings", "Index", "Training", null,new { #class = "my-class" })</li>
</ul>
</li>
<li>#Html.ActionLink("Financials", "BudgetVSActualChart", "Financial")</li>
<li>#Html.ActionLink("Admin", "AdminView", "PMODashboard")</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="navbar-text">Hello, #User.Identity.Name!</li>
</ul>
</div>
</div>
</div>
Any help will be appreciable
Thank you
Since you are loading in bootstrap anyway, you should use the bootstrap grid system. Add for example class="col-lg-3" to your div you want to rescrict in width. You can find more information about the grid system on Bootstrap grid page. This is always a nice way to make your page responsive!
Allright, I found the problem you are having:
The problem is that .nav-collapse has a with of auto.
There are 2 ways you could fix this.
Overwrite the .collapse in your css file like:
.navbar-collapse {
width:250px;
box-shadow: none;
border-top: 0px;
}
You find your bootstrap.css file and look for the following 2 rules:
#media (min-width: 768px) {
.navbar-collapse {
Here you remove the line that says width:auto;
I would advise you to use example 1.
Check out this jsfiddle
Let me know if it works for you!
Cheers
I used the class dropdown to the item on which dropdown will appear and class dropdown-menu in the un ordered list tag and it resolved my issue.
<ul id="nav" class="nav navbar-nav">
<li>#Html.ActionLink("DashBoard", "ExecutiveDashboard", "Charts")</li>
<li>#Html.ActionLink("Engagement Metrics", "EngagementMatrix", "Charts")</li>
<li>#Html.ActionLink("Quality Metrics", "Contact", "Home")</li>
<li class="dropdown">
#Html.ActionLink("People Aspects", "Contact", "Home")
<ul class="dropdown-menu navbar-inverse">
<li>#Html.ActionLink("Certifications", "Index", "Certification")</li>
<li>#Html.ActionLink("Trainings", "Index", "Training")</li>
</ul>
</li>
<li>#Html.ActionLink("Financials", "BudgetVSActualChart", "Financial")</li>
<li>#Html.ActionLink("Admin", "AdminView", "PMODashboard")</li>
</ul>
I am trying to customize bootstrap default fixed top nav to make it like one in images below. I am using latest twitter bootstrap 3.1.1. If you know please help me. You can even help me with any repository for it. The one in image is from i purchased which is using bootstrap 2x but i want to update it to 3x and use it in another template.
<div class="topHeaderSection">
<div class="header">
<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="index.html"><img src="assets/custom/img/logo.png" alt="My web solution" /></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li class="dropdown">
Services <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
<li>About us</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
You need to take your dropdown button out of the div with the collapse class, and put it into the navbar-header div. Then create an additional navbar-header for the application title.
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Title - manually pull it left-->
<div class="navbar-header pull-left">
#Html.ActionLink("Application name", "Index", "Home", null, new { #class = "navbar-brand" })
</div>
<!-- Buttons that won't collapse - and manually pull right-->
<div class="navbar-header pull-right">
<!-- Your drop down button that is not part of the collapse group -->
<ul class="nav pull-left">
<li class="dropdown pull-right">
Services <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
</ul>
<!-- The normal bootstrap button to show collapsed menu items -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Regular collapsed items -->
<div class="navbar-collapse collapse navbar-right">
<ul class="nav navbar-nav pull-right">
<li>About us</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
Check out this answer to a similar question: https://stackoverflow.com/a/22978968/1721571.
Included in this answer is a link to a fiddle which should help you. I tried it out and it worked well without any changes.
Here's the link if you want to jump straight in. Fiddle: http://jsfiddle.net/nomis/n9KtL/1/
UPDATE
Your additional requirements may require some JavaScript. From my understanding you want the navbar to be static until the user scrolls down to the point where the navbar reaches the top of the window. Then you want it to be fixed.
Add your Contact div above the first navbar element. I have made it a navbar-default so the difference is more clear. You don't have to use the bootstrap nav or container classes. You can create your own and get the style to your liking:
<div class="navbar navbar-default navbar-static-top" style="margin-bottom:0px" role="navigation">
<div class="container">
<div class="text-info">Small div with contact information</div>
</div>
</div>
Now change the original navbar to static to start off with. We will also give it a menu class so we can select it with jQuery:
<div class="navbar navbar-inverse navbar-static-top menu" role="navigation">
For the JavaScript:
$(document).ready(function () {
var menu = $('.menu');
var origOffsetY = menu.offset().top;
function scroll() {
if ($(window).scrollTop() >= origOffsetY) {
$('.menu').addClass('navbar-fixed-top');
$('.body-content').addClass('menu-padding');
} else {
$('.menu').removeClass('navbar-fixed-top');
$('.body-content').removeClass('menu-padding');
}
}
document.onscroll = scroll;
});
Notice how I have added a class to the body-content, this stops the content disappearing behind the navbar-fixed when it changes class.
.menu-padding {
padding-top: 80px;
}
Here is the complete fiddle: http://jsfiddle.net/seanobr/wsNYQ/
Here's what I have, I've tried moving around my section inside the "brand" and do a pull-right, outside the brand and outside the collapse and do a pull-left/right, while also trying to place it before or after the collapse section.
When adding it to the brand section it works, but it goes down to a new line. How do I keep it on the same line?
<body>
<header>
<nav class="navbar navbar-default navbar-inverse" role="navigation" style="font-size: 18px">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand site-title" style="text-decoration: none; font-size: 24px; font-weight:bold">#Html.ActionLink("Manager", "Index", "Player")</div>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse navbar-right">
<ul class="nav navbar-nav">
#* <li class="active">#Html.ActionLink("Home", "Index", "Player")</li>
<li class="active">#Html.ActionLink("Match", "Index", "Match")</li> <li class="dropdown">
Profile <b class="caret"></b>
<ul class="dropdown-menu">
<li>#Html.ActionLink("Change Password", "ManagePassword", "Account")</li>
<li>#Html.ActionLink("Update Profile Info", "UpdateProfile", "Account")</li>
<li>#Html.ActionLink("Log Off", "LogOff", "Account")</li>
</ul>
</li>
</ul>
</div>
<div>
<!-- I don't want it apart of the collapsible portion -->
<div class="navbar-right">
<ul class="nav navbar-nav">
<li class="active">#Html.ActionLink("Match", "Index", "Match")</li>
</ul>
</div>
</div>
</div>
</nav>
</header>
Below is an example that shows how to have just about any kind of 'vanilla bootstrap' NAVBAR configuration you could want. It includes a site title, both collapsing and non-collapsing menu items aligned left or right, and static text. Be sure to read the comments to get a fuller understanding of what you can change. Enjoy!
Fiddle: http://jsfiddle.net/nomis/n9KtL/1/
Fiddle with clearfix and expanded options on left side like normal: http://jsfiddle.net/jgoemat/u1j8o0n3/1/
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Title -->
<div class="navbar-header pull-left">
GNOMIS
</div>
<!-- 'Sticky' (non-collapsing) right-side menu item(s) -->
<div class="navbar-header pull-right">
<ul class="nav pull-left">
<!-- This works well for static text, like a username -->
<li class="navbar-text pull-left">User Name</li>
<!-- Add any additional bootstrap header items. This is a drop-down from an icon -->
<li class="dropdown pull-right">
<span class="glyphicon glyphicon-user"></span><b class="caret"></b>
<ul class="dropdown-menu">
<li>
Profile
</li>
<li>
Logout
</li>
</ul>
</li>
</ul>
<!-- Required bootstrap placeholder for the collapsed menu -->
<button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
</div>
<!-- The Collapsing items navbar-left or navbar-right -->
<div class="collapse navbar-collapse navbar-left">
<!-- pull-right keeps the drop-down in line -->
<ul class="nav navbar-nav pull-right">
<li>News
</li>
<li>Shop
</li>
</ul>
</div>
<!-- Additional navbar items -->
<div class="collapse navbar-collapse navbar-right">
<!-- pull-right keeps the drop-down in line -->
<ul class="nav navbar-nav pull-right">
<li>Locator
</li>
<li>Extras
</li>
</ul>
</div>
</div>
</nav>
You should be able to use pull-left and pull-right in 2 nav-header's to prevent the link from collapsing.
See: http://bootply.com/104747
<nav class="navbar navbar-default navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header pull-left">
<div class="navbar-brand">Brand</div>
</div>
<!-- I don't want it apart of the collapsible portion -->
<div class="navbar-header pull-right">
<ul class="nav navbar-nav pull-left">
<li class="active">No Collapse </li>
</ul>
<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>
</div>
<div class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li class="dropdown">
Profile <b class="caret"></b>
<ul class="dropdown-menu">
<li>Change Password</li>
<li>Update Profile Info</li>
<li>Log Off</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
Here is my other answer in Jade with some template logic just for fun :). See the other answer for additional info.
//- NOTE: 'navbar-default' styles the 'burger' and navbar text color, so remove it to add your own
nav(class="navbar navbar-default navbar-fixed-top", role="navigation")
.container
//- Title
.navbar-header.pull-left
a.navbar-brand(href='javascript:window.location.replace(window.location.origin);') GNOMIS
//- 'Sticky' (non-collapsing) right-side menu item(s)
.navbar-header.pull-right
ul.nav.pull-left
//- This works well for static text, maybe some initials
li.navbar-text.pull-left User Name
//- User Icon drop-down menu
li.dropdown.pull-right
a.dropdown-toggle(href='#', data-toggle='dropdown', style="color:#777; margin-top: 5px;")
span.glyphicon.glyphicon-user
b.caret
ul.dropdown-menu
li
a(href="/users/id", title="Profile")
| Profile
li
a(href="/logout", title="Logout")
| Logout
//- Required bootstrap placeholder for the collapsed menu
button.navbar-toggle(type='button', data-toggle='collapse', data-target='.navbar-collapse')
span.sr-only Toggle navigation
span.icon-bar
span.icon-bar
span.icon-bar
//- The Collapsing items navbar-left or navbar-right
.collapse.navbar-collapse.navbar-left
//- pull-right keeps the drop-down in line
ul.nav.navbar-nav.pull-right
li
a(href="/news") News
li
a(href="/shop") Shop
//- Additional navbar items
.collapse.navbar-collapse.navbar-right
//- pull-right keeps the drop-down in line
ul.nav.navbar-nav.pull-right
li
a(href="/locator") Locator
li
a(href="/extras") Extras
In my web page I have a Bootstrap 3 navbar:
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">Teachlab</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Help", '#' %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</div>
</nav>
<div class="container">
<%= yield %>
</div>
</body>
The problem is that navigation is to close to the edge of the screen. If I remove navbar-fixed-top from the navigation bar, it's working as I want.
Any hints?
Use .container-fluid as of 3.1.1.
The structure is not correct. .navbar-right goes on the .collapse container not on the ul.
SAMPLE: http://jsbin.com/eQIROsE/2/edit
<div class="navbar navbar-fixed-top navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="#">Project name</a>
<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>
</div>
<div class="navbar-collapse collapse navbar-right">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</div>
<!--/.navbar-collapse -->
</div>
I ended up with overriding following:
.navbar-nav.navbar-right:last-child {
margin-right: 0;
}
But maybe there's another solution?
It's broken and won't fix in 3.x. Hack it.
.navbar-right {
margin-right: 0px;
}
The solution to this could be
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<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="#">Project name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>Default</li>
<li>Static top</li>
<li class="active">Fixed top</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
It worked for me.
I really can't see why you'd have two .navbar-nav.navbar-right. Just wrap the navs in .navbar-right instead.
<div class="navbar-right">
<ul class="nav navbar-nav">...</ul>
<ul class="nav navbar-nav">...</ul>
</div>
I got exactly the same issue today!
According to Bootstrap doc <ul class="nav navbar-nav navbar-right"> is correct.
Like you, I solved the problem by setting the nav navbar-nav navbar-right margin-right to 0px without noticing unwanted effects.
Notice that the margin-right value of .navbar-text.navbar-right:last-child is 0px while .navbar-nav.navbar-right:last-child margin-right value is -15px... Bizarre?
https://github.com/twbs/bootstrap/issues/13325
My not so elegant solution, but does the job very quickly, add a last list item;
<li><span> </span></li>
If you have problem with
margin-right: -15px;
in .navbar-right then just add in your css styles
.navbar-right {
margin-right: 0px;
}
and if this still doesn't work clear your browser from all history when your webstie was running and debug it again. It works :)
(Fixed in asp.net mvc)
I had the same problem in asp.net mvc c#, the way i fix it was by going to Contents/bootstrap.css i located the .navbar{} class and i add it a padding of 5 px,that worked for me.
Heres how it looks when you find it..