Submenu with bootstrap - css

I am not so expert in CSS and Bootstrap so I can not build 2 submenus.
Do you have a simple solution for me?
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<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>
<a class="navbar-brand" href="index.php">SAI</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 class="dropdown">Titolo <b class="caret"></b>
<ul class="dropdown-menu">
<li>Sottotitolo 1</li>
<li>Sottotitolo 2</li>
<li class="dropdown">Sottotitolo 3 <b class="caret"></b>
<ul class="dropdown-menu">
<li>Nuovo sottotitolo 1</li>
<li>Nuovo sottotitolo 2</li>
<li>Nuovo sottotitolo 3</li>
<li>Nuovo sottotitolo 4</li>
<li>Nuovo sottotitolo 5</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
I have found some solutions on this site but they are too complex for me because I also have a few problems with the English language.
Thanks
Giampiero

I have made a small example for you that implements a Bootstrap dropdown with a small custom addition to support a sub-menu that opens on hover:
HTML
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li class="sub-menu">Sub-menu <span class="glyphicon glyphicon-play"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
</ul>
</div>
CSS (compiled from LESS)
li.sub-menu {
position: relative;
}
li.sub-menu span.glyphicon {
font-size: 0.7em;
}
li.sub-menu:hover .dropdown-menu {
display: block;
top: 0;
left: 100%;
}
You can see this working example here: http://codepen.io/anon/pen/amvavW
You should read the documentation on how to create dropdown-menus with Bootstrap:http://getbootstrap.com/components/#dropdowns
They have practical explanations that comes bundled with some code and working examples.
As much as I remember(correct me if I am wrong): Bootstrap currently does not natively support N-levels dropdown menus, so what you do is kind of use their built-in dropdown implementation and add a bit of custom CSS to get more sub-menu levels working in the way that you desire.
Hope it helps a bit!

Related

CSS - Bootstrap - Navbar width narrowed mobile button

How to change navbar/container width? Bootstrap 3
While following this I am super confused.
I am still fairly new in CSS, so I am still playing around a lot with bootstrap.
I added a div right outside of the navbar div to contain the total width.
.navbar-outer {
width:1000px;
margin-left: auto;
margin-right: auto;
}
That worked well, but as soon as I narrow the browser. The "Mobile" button no longer shows. Any suggestion on changes while keeping everything intact in the css? This is for bootstrap 3.3.4.
Full code below:
<nav class="navbar navbar-default">
<div class="navbar-outer">
<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" href="#">Brand</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">
<li class="dropdown">
Action <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<li class="dropdown">
<img src="testimage.jpg" style="width: 25px; height: 25px;" alt="..." class="img-circle"> Me <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
</nav>
I think it might be that you are setting the width with px, meaning the collapsing feature of the Bootstrap navbar cannot be triggered. I believe it collapses at 768px.
Using min-width and max-width:
.navbar-outer {
max-width:1000px;
min-width:767px;
margin-left: auto;
margin-right: auto;
}
http://jsfiddle.net/frank184/m3n3r1tg/

Twitter Bootstraps Yamm3 dropdown floated right... strange?

I'm using Yamm3 mega menu for Bootstrap. I have a class of navbar-right on the nav ul. When the Bootstraps default dropdown is open however the dropdown is floated all the way to the right of the container. How can I align the dropdown menus under their corresponding dropdown-toggles?
HTML
<nav class="navbar yamm navbar-default navbar-fixed-top">
<div class="container">
<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" href="#">Brand</a>
</div>
<div class="site-nav collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Default DropDown
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>Link 1</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
<li class="dropdown yamm-fw">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button">
Yamm3 DropDown
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<div class="yamm-content">
<div class="row">
<div class="col-sm-3">.col-sm-3</div>
<div class="col-sm-3">.col-sm-3</div>
<div class="col-sm-3">.col-sm-3</div>
<div class="col-sm-3">.col-sm-3</div>
</div>
</div>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Default DropDown
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>Link 1</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
<li class="dropdown yamm-fw">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button">
Yamm3 DropDown
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<div class="yamm-content">
<div class="row">
<div class="col-sm-3">.col-sm-3</div>
<div class="col-sm-3">.col-sm-3</div>
<div class="col-sm-3">.col-sm-3</div>
<div class="col-sm-3">.col-sm-3</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
YAMM3 CSS
.yamm .nav,
.yamm .collapse,
.yamm .dropup,
.yamm .dropdown {
position: static;
}
.yamm .container {
position: relative;
}
.yamm .dropdown-menu {
left: auto;
}
.yamm .yamm-content {
padding: 20px 30px;
}
.yamm .dropdown.yamm-fw .dropdown-menu {
left: 0;
right: 0;
}
Here's a js fiddle of the nav...
js fiddle : link
The .dropdown-menu-right rule in dropdowns.less is causing the issue.
.dropdown-menu-right {
left: auto; // Reset the default from `.dropdown-menu`
right: 0;
}
It is much easier and more convenient to simply add a float:right; in a new class on your menu as opposed to changing the whole structure e.g
<div class="site-nav collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav pull-right">
This will keep all the floats inplace and you therefore only need to add a right:0; to the navigation drop down which sits against the right side of the page to get he desired effect.
see js fiddle
Adding this to my yamm3.css worked reliably for me.
// ensure a good position
.nav.navbar-right .dropdown-menu {
left: auto;
right: auto;
}

When I add a small tag in bootstrap navbar, why does line-height increase 1px?

When I add a <small> tag in a Twitter Bootstrap navbar, why does line-height increase by 1px?
<li><small>welcome</small>Link</li>
<a> tag 21px , <li> tag 51px
I want to know why?
<nav class="navbar navbar-default" role="navigation">
<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" href="#">Brand</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">
<li class="active">Link <span class="sr-only">(current)</span></li>
<li><small>welcome</small>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
try this in your css file (to override bootstrap.css):
.navbar-nav>li>a {
line-height: inherit;
}
you will get rid of the 1px.

Have <li> inside navigation <li> in Bootstrap 3?

How to add element in navigation to look like this
For now i have this, i dont need the styling of lines etc, only focus on langauge selector to be on top of other. Here is what i have for now
<nav class="navbar" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-main">
<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="#">
<img src="http://placehold.it/150x50&text=Logo" alt="">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse-main">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Home
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
</ul>
</li>
<li class="dropdown">
Home
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
</ul>
</li>
<li class="dropdown">
Home
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
</ul>
</li>
<li class="dropdown">
Home
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
</ul>
</li>
<li>
<ul>
<li>History</li>
<li>Misson statement</li>
<li>Employment</li>
</ul>
</li>
<li>History</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</nav>
Working jfiddle
http://jsfiddle.net/y9RgH/

Restoring expanded responsive navbar sub-menu creates scrollbar Bootstrap 3.0.2

I know this issue was covered in another post but his fix didn't work for me since I have a drop down sub-menu. Is there away just to make the menu collapse when switching between the two so the scroll bars don't appear?
Submenu css used
[http://bootsnipp.com/snippets/featured/multi-level-dropdown-menu-bs3][1]
Fixed Tired
This is a known issue in 3.0.2
(https://github.com/twbs/bootstrap/issues/11243)
A workaround:
.navbar-collapse.in {
overflow-y: visible; } Demo: http://bootply.com/96924
Skelly
Restoring expanded responsive navbar menu creates scrollbar in Bootstrap 3.0.2
My CSS Menu
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<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>
<a class="navbar-brand" href="index.php">Chesapeake Controls Inc.</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div style="display: inline-block;" class="pull-right">
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
Capabilities<b class="caret"></b>
<ul class="dropdown-menu">
<li class="dropdown-submenu">Building Automation Systems
<ul class="dropdown-menu">
<li>Products </li>
<li>Services </li>
</ul>
</li>
<li class="dropdown-submenu">HVAC Service
<ul class="dropdown-menu">
<li>Maintenance </li>
<li>Installation </li>
</ul>
</li>
</ul>
</li>
<li class="dropdown">
Projects<b class="caret"></b>
<ul class="dropdown-menu">
<li>Building Automation</li>
<li>HVAC</li>
</ul>
</li>
<li>Careers</li>
<li>Contact Us</li>
<li class="dropdown">
Login<b class="caret"></b>
<ul class="dropdown-menu">
<li>Customer Portal</li>
<li>PPS Maintenance</li>
<li class="divider"></li>
<li>File Server</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</div>
</nav>

Resources