Bootstrap Collapsed Responsive Navbar Height - html

I have a Bootstrap menu with the following structure:
<nav class="navbar navbar-fixed-top">
<div class="navbar-inner">
<a class="brand" href="/">
<span class="title">Some Title</span>
</a>
<a 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>
</a>
<div class="nav-collapse collapse">
<ul class="nav" data-bind="foreach: navRoutes">
<li><a data-bind="css: { active: isActive() }, attr: { href: hash }, text: name"></a></li>
</ul>
<ul class="nav pull-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"/> Admin<b class="caret"></b></a>
<ul class="dropdown-menu pull-right">
<!-- ko foreach: adminRoutes -->
<li><a data-bind="attr: { href: hash }, html: caption"></a>
<!-- /ko -->
</ul>
</li>
<li><a data-bind="click: logOff" href="#"><i class="icon-signout"/> Log Off</a></li>
</ul>
</div>
<div class="loader pull-right" data-bind="css: { active: showLoader }">
<i class ="icon-spinner icon-2x icon-spin" ></i>
</div>
</div>
</nav>
When the screen is resized such that the width reduces below the threshold set in #navbarCollapseWidth in variables.less the menu does indeed collapse. However the height of the navbar increases from 59px to 126px. If the width is increased back above the threshold then the navbar height reverts to a height of 59px. I want the navbar height to stay the same when collapsed i.e. to stay at 59px. Is the increase expected behaviour? How can I achieve the behaviour that I am looking for?

I found that the problem was actually the last div with a class of "loader pull-right" that was causing the problem. I worked around the problem by moving this div inside the div with a class of "nav-collapse collapse". Not entirely satisfactory - but better.

Related

How to get hamburger icon to show before overlap in navbar

I added a new menu item to a navbar, but now when resizing smaller, the top Account menu item in yellow(see screenshot)(the div with 'navbar-right-container' in the HTML) moves down into the main navbar. If I resize even smaller, the hamburger icon shows up. I want the hamburger icon to show up before the top menu item overlaps into the other navbar. Below is a snippet of the HTML. I tried adding padding to the body as suggested by other posts but that did not work. How can I get the hamburger icon to show up before it overlaps? Thanks.
<div id="navigation" class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-expand-background">
</div>
<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 class="navbar-brand">
</div>
</div>
<div class="navbar-collapse collapse">
<div class="navbar-middle-container">
<ul class="nav navbar-nav navbar-middle">
<li>
<a href="javascript:openModalAction('/Manage/Accounts')" class="navbar-account-switch">
<span>Account:<br />My Account</span> <span class="caret caret-right caret-collapsible"></span>
</a>
</li>
<li class=" nobr">
<a href="/" title="My Dashboard" >
DASHBOARD
</a>
</li>
<li class=" dropdown nobr">
<a href="/Quotes" class="dropdown-toggle" data-toggle="dropdown">
ACCOUNTS
<b class="caret caret-collapsible"></b>
</a>
<div class="dropdown-menu dropdown-menu-multicolumn ">
<div class="dropdown-menu-head"><div class="dropdown-menu-head-border"></div></div>
<table class="table table-condensed">
<tr>
<td>
<ul class="dropdown-menu-col">
<li class="nobr"><div class="dropdown-menu-col-header">MANAGE</div></li>
.......................................<div class="navbar-right-container">
<ul class="nav navbar-nav navbar-right">
<li class=" dropdown nobr">
<a href="/Quotes" title="Manage Account" class="dropdown-toggle" data-toggle="dropdown">
My name
<b class="caret"></b>
</a>
My Navbar
It is hard to presume without a working example. But almost certainly you should add some to your CSS breakpoint. Add 12em or 200px. Or make an entirely new breakpoint to focus specifically on that element.
You could resort to hacky tricks like negative margin width to offset the new element's impact on the layout. This may affect your ability to click and require even more rules.

Bootstrap collapsed navbar showing empty

When I click on the hamburger menu in my nicely collapsed bootstrap navbar on my phone, the layout slides to the side as expected, but shows me an empty white (or whatever body background colour I have) bar instead of the navigation. Closer inspection with firebug showed that upon clicking the button, some classes got changed on the navbar-collapsebut it remains tagged as invisible.
I have recompiled Bootstrap from LESS to change the point at which it collapses, but the issue seems persistent even with 'vanilla' bootstrap.
Code:
<nav class="navbar transparent navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header" style="padding-right: 0px; min-width: 50px;">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
<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 hidden-xs hidden-sm" href="index.html"><span class="glyphicon glyphicon-home" style="padding-right: 0px;"></span></a><a class="navbar-brand hidden-lg hidden-md" href="index.html">De Fijnkost</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navigation-example-2">
<ul class="nav navbar-nav navbar-right">
<li>
Fijne Vleeswaren
</li>
<li>
Bereide Gerechten
</li>
<li>
Eigen salades
</li>
<li>
Kazen & Kaasschotels
</li>
<li>
Belegde Broodjes
</li>
<li>
Contact
</li>
<li>
Nieuws
</li>
<li class="dropdown">
<a class="dropdown-toggle btn btn-white btn-fill" data-toggle="dropdown" href="#">Bestel <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Kaasschotel
</li>
<li class="disabled">
Broodjes
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid-->
</nav>
Same thing happens on pages without the transparent or navbar-fixed-top class. transparent is added by my CSS. Page is visible on defijnkost.be
Your .navbar-collapse is set to display: none !important as far as I can see.
If you set it to display: block in your mobile view media query it should show up just fine.

How to display text only in the collapsable navbar

Navbar how it should be:
I want the text idealize, develop, prototype and about to appear next to the icons only in the collapsable navbar. The text appears on larger viewport sizes, too, what I don't want:
HTML
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" id="logo" href="#">
<img src="images/avezlogo.png">
</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li id="orange"><a href="#idealize">
<img src="images/bulb.png"><span class="collapse">idealize</span>
</a></li>
<li id="cyan"><a href="#develop">
<img src="images/laptop.png"><span class="tittle">develop</span>
</a></li>
<li id="purple"><a href="#prototype">
<img src="images/printer.png"><span class="tittle">prototype</span>
</a></li>
<li id="red" class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#about">
<img src="images/dots.png" id="dots"><span class="tittle">about</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
Sorry about any noob mistakes on my code. I'm new to Bootstrap and web design. Any help is appreciated. Thanks!
You can use display: none; inside of a media query to target and hide your images at the mobile breakpoint. See example.
#media (min-width: 768px) {
.navbar-inverse .navbar-nav li img {
display: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" id="logo" href="#">
<img src="images/avezlogo.png">
</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li id="orange">
<a href="#idealize">
<img src="images/bulb.png"><span class="collapse"> idealize</span>
</a>
</li>
<li id="cyan">
<a href="#develop">
<img src="images/laptop.png"><span class="tittle"> develop</span>
</a>
</li>
<li id="purple">
<a href="#prototype">
<img src="images/printer.png"><span class="tittle"> prototype</span>
</a>
</li>
<li id="red" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#about">
<img src="images/dots.png" id="dots"><span class="tittle"> about</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</nav>
That's how it should behave. Links should be seen in all viewport sizes. If you only want to see the links in the collapsable navbar and not in the not-collapsable navbar, you can do this:
#media (min-width: 768px) {
#myNavbar .navbar-right {
display: none;
}
But then you see in larger viewport sizes a blank navbar without a toggle icon on the right side. And that's not what you want, I think.
If you want a collapsable navbar all the time, the best solution would be to customize the Bootstrap CSS here:
Bootstrap customize grid
and set the #grid-float-breakpoint to a large width, e.g. 3000px. Download and compile and the CSS should do it.
the media query worked fine. Thanks a lot. I was also wondering. Why doesn't the dropdown menu in the first image close after clicking one of the links? I have to click the menu button again for it to close. How could I change this? Thanks again.

Bootstrap navbar height changed on inserting brand image

I am new to HTML and CSS and have started coding in the last 4 days. I found bootstrap very useful to get things moving quickly.
Here is my attempt at getting a Navbar with transparency and fixed to the top.
http://jsfiddle.net/revanur/mf5wc/4/
<!-- Top-Navigation-Bar -->
<div class="row-fluid">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner" id="topbar">
<div class="container"> <img class = "brand" src="http://placehold.it/269x50" alt="SparkCharger" />
<button id="topbtn" 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>
<div class="nav-collapse">
<ul class="nav pull-right">
<li class="active">
<form class="navbar-search brand">
<input type="text" class="search-query" placeholder="Search">
</form>
</li>
<li> <h5> Discover </h5>
</li>
<li> <h5> Blog </h5>
</li>
<li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"><h5>Start <span class="caret"></span></h5></a>
<ul class="dropdown-menu">
<li> <h6> Login </h6>
</li>
<li> <h6> Signup </h6>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- /Top-Navigation-Bar -->
However, the height of the navbar seems to change based on brand image size. I have no problem with that but I notice significant spacing between the image and the navbar top and bottom. How do I change this. Also, is it possible to fix the navbar size so that the navbar does not have a mind of its own.
There are a few things affecting the height of the navbar:
div class="navbar-inner" (5px padding)
img class="brand" (10px padding)
the size of the image
You can remove the padding by:
img.brand {
padding: 0;
}
And/Or you can specify the height of the navbar:
div.navbar-inner {
height: 10px;
}
Use something like this:
.brand {height: 25px;}
Demo: Fiddle

Display text while hover on menu

I've been working on my website using twitter bootstrap, and there's one thing that I'm probably not doing right.
I want to have some text to appear in the menu while I mouse hover on one of the links. Here's what I have:
HTML:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<a 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>
</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li>Back</li>
<li><a href="prev_page.html" class=""previous >Previous</a></li>
<li><a href="next_page.html" class="next" >Next</a></li>
<li><span class="shownext">View next</span></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar navbar-inverse-->
CSS:
.nav .shownext {
font-weight: normal;
font-style: italic;
font-size: 11px;
display: none;
}
.next:hover + .nav .shownext {
display: block;
}
Any help will be appreciated.
You can use tooltips to be fancy or just the title attribute:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<a 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>
</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li>Back</li>
<li><a href="prev_page.html" data-toggle="tooltip" data-placement="bottom" title="second tooltip" class=""previous >Previous</a></li>
<li><a href="next_page.html" data-toggle="tooltip" data-placement="top" title="third tooltip" class="next" >Next</a></li>
<li><span class="shownext" data-toggle="tooltip" data-placement="top" title="view next">View next</span></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar navbar-inverse-->
<script>$('li a').tooltip(options)</script>
Result
This is kinda what You asked. But since Your question wasn't to specific I don't think it's really what You wanted.
http://jsfiddle.net/xM6u9/1/
<div class="navbar">
<div class="navbar-inner"> <a class="brand" href="#">Title</a>
<ul class="nav">
<li class="active">Home
</li>
<li>Link
</li>
<li>Link
</li>
<li class="shownext">Next
</li>
</ul>
</div>
</div>
css:
.shownext { display: none; }
li:hover + .shownext { display: block; }
"Next" is showing up when You hover on last item.