Bootstrap drop down list goes under the nav bar - html

Here is how it looks like when the drop-down menu appears.
Nav-bar :
<nav class="navbar navbar-default" role="navigation">
<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>
<a class="navbar-brand" href="#">Categories</a>
...
Drop-down:
<ul class="dropdown-menu">
<li>
<div class="panel panel-default">
<div class="panel-body">
<div class="panel-info">
<p><strong>Black Dress</strong></p>
<p>Each Price : <strong>Rs. 500.00</strong></p>
<p>Quantity : <input type="number" value="3"/>
<a href="#"><span class="glyphicon glyphicon-refresh"></span></p>
....
Tried with positioning(position:relative).But couldn't get the required result. (Drop-down over the nav-bar) .Thanks in advance.
Here is an example of my work.

Why the given z-index doesn't work?
.dropdown-menu is not in the same level of .navbar so give z-index:1010; and position:relative; to the #header(its parent).
Jsfiddle

Related

Add text inside bootstrap mobile menu button

How to add a text inside bootstrap mobile menu button?
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-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 sidebar-navbar-collapse collapse" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
<li class="nav_bar_title"></li>
<li class="page_item"></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
Example, what i want to achieve:
you can add a list item just for the text and the rest for menu items:
<li class="page_item class-for-styling-the-text">your text here</li>
and use the a certain class to style that element or use css :first-child selector.
hope that helps.
Something like this :
Bootply: https://www.bootply.com/JH4FMuvYMe
HTML
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="text">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse sidebar-navbar-collapse collapse" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
<li class="nav_bar_title"></li>
Css
span.text {
float: left;
margin-right: 30px;
}
.navbar-toggle .icon-bar{
margin-left: auto;
}
you can try this:
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span style="display:inline-block; margin:2px;">menu text</span>
<span style="display:inline-block;">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>

How To: Bootstrap3 Navbar - why is there a select list in my nav?

I've got this bootstrap3 navbar in my page, and the dang thing auto-spawns a drop-down-list for all the items in the navbar UL. How can I stop this?
My Navbar code:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container" style="margin-left: 0; margin-right: 0;">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img id="brand_logo_img_cc" src="/Content/images/logo.gif" alt="" style="width: 295px; height: 47px;" /></a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#mainHeaderNavbar" aria-expanded="false" aria-controls="mainHeaderNavbar">
<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 id="mainHeaderNavbar" class="navbar-collapse collapse" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">Home</li>
<li class="dropdown"><!-- other generated links --></li>
</ul>
</div>
</div>
</nav>
Since there's no drop-down-list in my code (aside from the nav drop down buttons), I assume this Go To drop-down is auto-generated by Bootstrap, but I don't know how to get rid of it.

Bootstrap navbar with element on right and left side beside menu icon

I'm trying to build a navbar with bootstrap. My navbar should have two elements:
Close-icon on the left side of the bar
Label element on the right side of the bar, but it should be placed left to the menu-icon (which is shown on small devices). If there is no menu-icon, the label element should be just on the right side of the bar
This is what I tried so far:
JSFiddle: http://jsfiddle.net/0jejx693/1/
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="nav navbar-nav nav-pills navbar-right">
<li><a class="navbar-brand"><i class="fa fa-power-off"></i></a></li>
<li>
<a href="/link">
<span class="label"><i class="fa fa-commenting"></i> 10</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
So the result should look like this:
small
| [icon] [lable] [menu] |
big
| [icon] [lable] |
Updated fiddle. Hmm, sry cause I deleted "label" class from span, but it was not showing the "fa" icon. So, was only for test. And, there's a label left to toggle-menu. I think that's what you want, am I right?
http://jsfiddle.net/kqemk0zk/
.label-cont{
position: absolute!important; /*Important used only to example. Could be overrated with hierarchy*/
right: 60px;
}
Something like this?
<nav id="mainNav" class="navbar navbar-default navbar-fixed-top affix-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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 page-scroll" href="#page-top"><i class="fa fa-power-off"></i></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/link">
<span class="label"><i class="fa fa-commenting"></i> 10</span>
</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>

Bootstrap 3: Navbar not full width

I'm currently trying to create a Navbar with 100% width in Bootstrap, but it isn't working like it should.
How can I scale the Navbar to 100% width?
<div class="container-fluid" style="border: 1px solid">
<!-- Navbar -->
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-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" href="#">Bootflat</a>
</div>
</div>
</nav>
</div>
</div>
</div>
Picture:
http://i.imgur.com/diqTvTP.png
Remove .row and .col-md-12 divs – they add padding. You only need to use them when you divide content in columns.
I think this code looks fine as per your requirements.
<div style="border: 1px solid">
<nav class="navbar navbar-default" role="navigation">
<div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-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" href="#">Bootflat</a>
</div>
</div>
</nav>
</div>
Please see here
You don't need the row and the grid col divs since the navbar will be at a full width at all times and you are using .container-fluid. Try this:
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-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" href="#">Bootflat</a>
</div>
</div>
</nav>
As happened to me, if you want it with the full width on the top (sticky). Adding fixed-top class to the nav will do.
<nav class="navbar fixed-top navbar-light bg-light">
<a class="navbar-brand" href="#">Fixed top</a>
</nav>
Just add the following css code body{padding:0;margin:0}. It worked for me.
Hope this helps.

Bootstrap 3.0 navigation on page resize

I'm new to Bootstrap and just attempting to get the responsive navigation to work. When I resize the window, I do see the collapsed navbar icon but it doesn't display the add link.
<div class="container">
<nav 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="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
My Books
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>Add</li>
</ul>
</div>
</div>
</nav>
</div>
I found the source of the problem.
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
In fact should be:
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#.navbar-collapse">
data-target should be the class name of the nav div.