How can I make other slide-down menus close when clicking on another menu item? Right now all menu items are opening one by one and they can only be closed by clicking on the item again.
Here's a demo: http://bootsnipp.com/snippets/33qKz
And here's the code
function htmlbodyHeightUpdate(){
var height3 = $( window ).height()
var height1 = $('.nav').height()+50
height2 = $('.main').height()
if(height2 > height3){
$('html').height(Math.max(height1,height3,height2)+10);
$('body').height(Math.max(height1,height3,height2)+10);
}
else
{
$('html').height(Math.max(height1,height3,height2));
$('body').height(Math.max(height1,height3,height2));
}
}
$(document).ready(function () {
htmlbodyHeightUpdate()
$( window ).resize(function() {
htmlbodyHeightUpdate()
});
$( window ).scroll(function() {
height2 = $('.main').height()
htmlbodyHeightUpdate()
});
});
/* Adding gvnix styles css - NO COPIAR */
#import 'http://geo-gvnix.rhcloud.com/resources/styles/standard.css';
/* Custom fixed navs */
header.navbar+nav.navbar {
/* margin-top: 20px;same margin-bottom .navbar */
}
.navbar.navbar-default.navbar-fixed-top {
margin-top: 50px;
}
.sidebar.navbar-fixed-top {
margin-top: 100px;
}
#media (min-width: 768px) and (max-width: 998px) {
.navbar.navbar-default.navbar-fixed-top {
margin-top: 100px;
}
.sidebar.navbar-fixed-top {
margin-top: 150px;
}
}
/* Custom navbar default: global*/
.navbar.navbar-default {
background-color: #f8f8f8;
border-color: #e7e7e7;
margin: 0;
border-radius: 0;
}
.navbar.navbar-default .navbar-brand {
color: #666;
text-shadow: none;
min-width: 150px;
}
.navbar.navbar-default .navbar-nav > li > a {
color: #666;
text-shadow: none;
}
.navbar.navbar-default .navbar-nav > li > a {
color: #666;
text-shadow: none;
}
.navbar.navbar-default .navbar-nav > li > a:hover {
color: #acc47f;
}
.navbar.navbar-default .navbar-nav > .active > a {
color: #fff;
background-color: #acc47f;
}
.navbar.navbar-default .navbar-nav > .active > a:hover {
color: #608224;
background-color: #acc47f;
}
.navbar.navbar-default .caret {
border-top-color: #ccc;
border-bottom-color: #ccc;
}
.navbar.navbar-default .caret:hover {
border-top-color: #333;
border-bottom-color: #333;
}
/* Custom sidebar menu */
/*Remove rounded coners*/
nav.sidebar.navbar {
border-radius: 0px;
}
nav.sidebar,
.main {
-webkit-transition: margin 200ms ease-out;
-moz-transition: margin 200ms ease-out;
-o-transition: margin 200ms ease-out;
transition: margin 200ms ease-out;
}
/* Add gap to nav and right windows.*/
.main {
padding: 10px 10px 0 10px;
}
/* .....NavBar: Icon only with coloring/layout.....*/
/*small/medium side display*/
#media (min-width: 768px) {
/*Allow main to be next to Nav*/
.main {
position: absolute;
width: calc(100% - 40px);
/*keeps 100% minus nav size*/
margin-left: 40px;
float: right;
}
/*lets nav bar to be showed on mouseover*/
nav.sidebar:hover + .main {
margin-left: 200px;
}
/*Center Brand*/
nav.sidebar.navbar.sidebar>.container .navbar-brand,
.navbar>.container-fluid .navbar-brand {
margin-left: 0px;
}
/*Center Brand*/
nav.sidebar .navbar-brand,
nav.sidebar .navbar-header {
text-align: center;
width: 100%;
margin-left: 0px;
}
/*Center Icons*/
nav.sidebar a {
padding-right: 13px;
min-width: 100px;
}
/*custom sidebar nav*/
nav.sidebar ul.nav.navbar-nav {
margin: 0;
}
nav.sidebar.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: white;
}
/*adds border top to first nav box */
nav.sidebar .navbar-nav > li:first-child {
border-top: 1px #e5e5e5 solid;
}
/*adds border to bottom nav boxes*/
nav.sidebar .navbar-nav > li {
border-bottom: 1px #e5e5e5 solid;
}
/*adds background on hover*/
nav.sidebar .navbar-nav > li:hover {
color: #fff;
background-color: #43600E;
}
/*removes border last element*/
nav.sidebar .navbar-nav > li.last {
border-bottom: none;
}
/* Colors/style dropdown box*/
nav.sidebar .navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
/*allows nav box to use 100% width*/
nav.sidebar .navbar-collapse,
nav.sidebar .container-fluid {
padding: 0 0px 0 0px;
}
/*colors dropdown box text */
.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: #777;
}
/*O quanto o menu irá esconder á esquerda*/
/*gives sidebar width/height*/
nav.sidebar {
width: 200px;
height: 100%;
margin-left: -270px;
float: left;
z-index: 8000;
margin-bottom: 0px;
}
/*give sidebar 100% width;*/
nav.sidebar li {
width: 100%;
}
/* Move nav to full on mouse over*/
nav.sidebar:hover {
margin-left: 0px;
}
/*for hiden things when navbar hidden*/
.forAnimate {
opacity: 0;
}
}
/* .....NavBar: Fully showing nav bar..... */
#media (min-width: 1330px) {
/* Allow main to be next to Nav
.main{
width: calc(100% - 200px); keeps 100% minus nav size
margin-left: 200px;
}
Show all nav
nav.sidebar{
margin-left: 0px;
float: left;
}
Show hidden items on nav
nav.sidebar .forAnimate{
opacity: 1;
} */
}
nav.sidebar .navbar-nav .open .dropdown-menu>li>a:hover,
nav.sidebar .navbar-nav .open .dropdown-menu>li>a:focus {
color: #CCC;
background-color: transparent;
}
nav:hover .forAnimate {
opacity: 1;
}
/*---- FIM SLIDE MENU*/
.nav-side-menu {
overflow: auto;
font-family: verdana;
font-size: 12px;
font-weight: 200;
background-color: #2e353d;
position: fixed;
top: 0px;
width: 300px;
height: 100%;
color: #e1ffff;
}
.nav-side-menu .brand {
background-color: #23282e;
line-height: 50px;
display: block;
text-align: center;
font-size: 14px;
}
.nav-side-menu .toggle-btn {
display: none;
}
.nav-side-menu ul,
.nav-side-menu li {
list-style: none;
padding: 0px;
margin: 0px;
line-height: 35px;
cursor: pointer;
/*
.collapsed{
.arrow:before{
font-family: FontAwesome;
content: "\f053";
display: inline-block;
padding-left:10px;
padding-right: 10px;
vertical-align: middle;
float:right;
}
}
*/
}
.nav-side-menu ul :not(collapsed) .arrow:before,
.nav-side-menu li :not(collapsed) .arrow:before {
font-family: FontAwesome;
content: "\f078";
display: inline-block;
padding-left: 10px;
padding-right: 10px;
vertical-align: middle;
float: right;
}
.nav-side-menu ul .active,
.nav-side-menu li .active {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
}
.nav-side-menu ul .sub-menu li.active,
.nav-side-menu li .sub-menu li.active {
color: #d19b3d;
}
.nav-side-menu ul .sub-menu li.active a,
.nav-side-menu li .sub-menu li.active a {
color: #d19b3d;
}
.nav-side-menu ul .sub-menu li,
.nav-side-menu li .sub-menu li {
background-color: #181c20;
border: none;
line-height: 28px;
border-bottom: 1px solid #23282e;
margin-left: 0px;
}
.nav-side-menu ul .sub-menu li:hover,
.nav-side-menu li .sub-menu li:hover {
background-color: #020203;
}
.nav-side-menu ul .sub-menu li:before,
.nav-side-menu li .sub-menu li:before {
font-family: FontAwesome;
content: "\f105";
display: inline-block;
padding-left: 10px;
padding-right: 10px;
vertical-align: middle;
}
.nav-side-menu li {
padding-left: 0px;
border-left: 3px solid #2e353d;
border-bottom: 1px solid #23282e;
}
.nav-side-menu li a {
text-decoration: none;
color: #e1ffff;
}
.nav-side-menu li a i {
padding-left: 10px;
width: 20px;
padding-right: 20px;
}
.nav-side-menu li:hover {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
#media (max-width: 767px) {
.nav-side-menu {
position: relative;
width: 100%;
margin-bottom: 10px;
}
.nav-side-menu .toggle-btn {
display: block;
cursor: pointer;
position: absolute;
right: 10px;
top: 10px;
z-index: 10 !important;
padding: 3px;
background-color: #ffffff;
color: #000;
width: 40px;
text-align: center;
}
.brand {
text-align: left !important;
font-size: 22px;
padding-left: 20px;
line-height: 50px !important;
}
}
#media (min-width: 767px) {
.nav-side-menu .menu-list .menu-content {
display: block;
}
}
body {
margin: 0px;
padding: 0px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!--nav sidebar -->
<aside>
<nav class="navbar navbar-inverse sidebar navbar-fixed-top" role="navigation">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<div class="nav-side-menu">
<div class="brand">Brand Logo</div>
<i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
<div class="menu-list">
<ul id="menu-content" class="menu-content collapse out">
<li>
<a href="#">
<i class="fa fa-dashboard fa-lg"></i> Dashboard
</a>
</li>
<li data-toggle="collapse" data-target="#products" class="collapsed active">
<i class="fa fa-gift fa-lg"></i> UI Elements <i class="fa fa-gift fa-lg btn pull-right" style="margin-top:5px"></i>
</li>
<ul class="sub-menu collapse" id="products">
<li class="active">CSS3 Animation
</li>
<li>General
</li>
<li>Buttons
</li>
<li>Tabs & Accordions
</li>
<li>Typography
</li>
<li>FontAwesome
</li>
<li>Slider
</li>
<li>Panels
</li>
<li>Widgets
</li>
<li>Bootstrap Model
</li>
</ul>
<li data-toggle="collapse" data-target="#service" class="collapsed">
<i class="fa fa-globe fa-lg"></i> Services <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="service">
<li>New Service 1</li>
<li>New Service 2</li>
<li>New Service 3</li>
</ul>
<li data-toggle="collapse" data-target="#new" class="collapsed">
<i class="fa fa-car fa-lg"></i> New <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="new">
<li>New New 1</li>
<li>New New 2</li>
<li>New New 3</li>
</ul>
<li>
<a href="#">
<i class="fa fa-user fa-lg"></i> Profile
</a>
</li>
<li>
<a href="#">
<i class="fa fa-users fa-lg"></i> Users
</a>
</li>
</ul>
</div>
</div>
</nav>
</aside>
<div class="main">
</div>
Your HTML structure is not quite what Bootstrap expects and you won't be able to use the easy way of data-parent attribute on this structure (the items should be divs and have the class panel anyway). Please see documentation for more info if interested. But for your problem and something you can make work directly into your HTML. I added toggle-this class to all the parent menu items which are toggled and added the attribute data-parent="menu-content" to them also. Then I just use this jQuery function to see if there are any menus expanded on click and collapse all the other than the one just clicked like this:
$(document).on('click', '.toggle-this', function(event) {
event.stopPropagation();
var $this = $(this);
var parent = $this.data('parent');
var actives = $('#' + parent).find('[aria-expanded="true"]');
if (actives && actives.length) {
hasData = actives.data('collapse');
actives.collapse('hide');
}
var target = $this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); //strip for ie7
$(target).collapse('toggle');
});
Here's a working JSFiddle: https://jsfiddle.net/thepio/x5j6v5fq/
Your html does not follow the documentation from bootstrap.
The right structure should be something like this:
<ul class="nav navbar-nav">
<li class="active">Dashboard</li>
<li class="dropdown">
UI Elements <span class="caret"></span>
<ul class="dropdown-menu">
<li>CSS3 Animation</li>
<li>General</li>
<li>Buttons</li>
...
</ul>
</li>
...
</ul>
I relize that this would mean you have to re-style some parts of your navigation, but it gives you the functionality that you want.
For more information check bootstraps documentation about navbars
Alternative you can make a little script to change/remove classes on the opened menu items when you click a new one.
Related
I am trying to make a drop-down menu that drops from image but I can't seem to make it work. How should I target the hover? Because everything I am trying is not working. How I am trying to initiate hover effect is shown at the end of CSS.
.area-left {
float: left;
}
.menu-icon {
width: 28px;
display: inline-block;
vertical-align: middle;
margin-top: 5px;
}
.menu-icon hr {
border: 2px solid #A5CF4C;
border-radius: 100px;
margin-top: 3px;
margin-bottom: 4px;
margin-right: 5px;
margin-left: 3px;
}
.area-left .menu li:hover {
background-color: rgba(165, 207, 76, 0.4);
}
.logo img {
vertical-align: middle;
margin-top: 2px;
}
.sub-menu ul {
background-color: rgba(255, 255, 255, 0.8);
}
.sub-menu li {
border: 1px solid green;
padding: 0px 5px;
}
.sub-menu .menu li:first-child {
margin-top: 3px;
}
.sub-menu ul li {
display: none;
}
.logo img:hover .sub-menu ul li {
display: block;
}
<div class="area-left">
<ul id="htc-menu" class="parent-menu">
<li class="logo ico-container">
<div class="menu-icon">
<hr/>
<hr/>
<hr/>
</div><img src="images/logo.png" alt="HTC Logo"></li>
<li class="sub-menu">
<ul class="menu">
<li>smartphones</li>
<li>accessories</li>
<li>virtual reality</li>
<li>fitness</li>
</ul>
</li>
</ul>
</div>
You're trying to access the .sub-menu as a child of .logo, despite them being siblings of each other.
Try:
.logo:hover + .sub-menu ul li {
display: block;
}
Or just:
#htc-menu:hover .sub-menu ul li {
display: block;
}
Try this :)
I purposely did not go with the adjacent CSS selector because once your mouse moves off the menu icon, the menu would disappear again, making it unhelpful. So you'll want to target the hover state of the parent element so that the menu remains visible while the mouse moves from the logo to the menu that just appears.
.area-left {
float: left;
}
.menu-icon {
width: 28px;
display: inline-block;
vertical-align: middle;
margin-top: 5px;
}
.menu-icon hr {
border: 2px solid #A5CF4C;
border-radius: 100px;
margin-top: 3px;
margin-bottom: 4px;
margin-right: 5px;
margin-left: 3px;
}
.area-left .menu li:hover {
background-color: rgba(165, 207, 76, 0.4);
}
.logo img {
vertical-align: middle;
margin-top: 2px;
}
.sub-menu ul {
background-color: rgba(255, 255, 255, 0.8);
}
.sub-menu li {
border: 1px solid green;
padding: 0px 5px;
}
.sub-menu .menu li:first-child {
margin-top: 3px;
}
.sub-menu ul li {
display: none;
}
.logo img:hover .sub-menu ul li {
display: block;
}
/* Tessa's Changes */
#htc-menu {
list-style: none;
}
#htc-menu:hover li.sub-menu ul.menu li {
display: block;
}
<div class="area-left">
<ul id="htc-menu" class="parent-menu">
<li class="logo ico-container">
<div class="menu-icon">
<hr/>
<hr/>
<hr/>
</div><img src="images/logo.png" alt="HTC Logo">
</li>
<li class="sub-menu">
<ul class="menu">
<li>smartphones</li>
<li>accessories</li>
<li>virtual reality</li>
<li>fitness</li>
</ul>
</li>
</ul>
</div>
i'm getting expended menu bar with subitems when i run my jsp file and even it is not collapsing on click mean no response from the menu bar i already tried different ways to resolve this issue but unable to resolve.
HTML
<link
href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"
rel="stylesheet">
<div class="nav-side-menu">
<div class="menu-list">
<ul id="menu-content" class="menu-content collapse out">
<li><a href="#"> <i class="fa fa-home fa-lg"></i>
Home
</a></li>
<li data-toggle="collapse" data-target="#products"
class="collapsed active"><a><i
class="fa fa-gift fa-lg"></i> UI Elements <span class="arrow"></span></a>
</li>
<ul class="sub-menu collapse" id="products">
<li>CSS3 Animation</li>
<li>General</li>
<li>Buttons</li>
<li>Tabs & Accordions</li>
<li>Typography</li>
<li>FontAwesome</li>
<li>Slider</li>
<li>Panels</li>
<li>Widgets</li>
<li>Bootstrap Model</li>
</ul>
<li data-toggle="collapse" data-target="#service" class="collapsed">
<a><i class="fa fa-globe fa-lg"></i> Services <span
class="arrow"></span></a>
</li>
<ul class="sub-menu collapse" id="service">
<li>New Service 1</li>
<li>New Service 2</li>
<li>New Service 3</li>
</ul>
<li data-toggle="collapse" data-target="#new" class="collapsed">
<a><i class="fa fa-bus fa-lg"></i> New <span
class="arrow"></span></a>
</li>
<ul class="sub-menu collapse" id="new">
<li>New New 1</li>
<li>New New 2</li>
<li>New New 3</li>
</ul>
<li><a href="#"> <i class="fa fa-user fa-lg"></i> Profile
</a></li>
<li><a href="#"> <i class="fa fa-users fa-lg"></i> Users
</a></li>
</ul>
</div>
</div>
css for nav
CSS
.nav-side-menu {
overflow: auto;
font-family: verdana;
font-size: 12px;
font-weight: 200;
background-color: #2e353d;
position: fixed;
top: 0px;
width: 24%;
height: 100%;
color: #e1ffff;
}
.nav-side-menu .brand {
background-color: #23282e;
line-height: 50px;
display: block;
text-align: center;
font-size: 14px;
}
.nav-side-menu .toggle-btn {
display: none;
}
.nav-side-menu ul, .nav-side-menu li {
list-style: none;
padding: 0px;
margin: 0px;
line-height: 35px;
cursor: pointer;
}
.nav-side-menu ul :not(collapsed) .arrow:before, .nav-side-menu li :not(collapsed) .arrow:before
{
font-family: FontAwesome;
content: "\f078";
display: inline-block;
padding-left: 10px;
padding-right: 10px;
vertical-align: middle;
float: right;
}
.nav-side-menu ul .active, .nav-side-menu li .active {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
}
.nav-side-menu ul .sub-menu li.active, .nav-side-menu li .sub-menu li.active
{
color: #d19b3d;
}
.nav-side-menu ul .sub-menu li.active a, .nav-side-menu li .sub-menu li.active a
{
color: #d19b3d;
}
.nav-side-menu ul .sub-menu li, .nav-side-menu li .sub-menu li {
background-color: #181c20;
border: none;
line-height: 28px;
border-bottom: 1px solid #23282e;
margin-left: 0px;
}
.nav-side-menu ul .sub-menu li:hover, .nav-side-menu li .sub-menu li:hover
{
background-color: #020203;
}
.nav-side-menu ul .sub-menu li:before, .nav-side-menu li .sub-menu li:before
{
font-family: FontAwesome;
content: "\f105";
display: inline-block;
padding-left: 10px;
padding-right: 10px;
vertical-align: middle;
}
.nav-side-menu li {
padding-left: 0px;
border-left: 3px solid #2e353d;
border-bottom: 1px solid #23282e;
}
.nav-side-menu li a {
text-decoration: none;
color: #e1ffff;
}
.nav-side-menu li a i {
padding-left: 10px;
width: 20px;
padding-right: 20px;
}
.nav-side-menu li:hover {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
#media ( max-width : 767px) {
.nav-side-menu {
position: relative;
width: 100%;
margin-bottom: 10px;
}
.nav-side-menu .toggle-btn {
display: block;
cursor: pointer;
position: absolute;
right: 10px;
top: 10px;
z-index: 10 !important;
padding: 3px;
background-color: #ffffff;
color: #000;
width: 40px;
text-align: center;
}
.brand {
text-align: left !important;
font-size: 22px;
padding-left: 20px;
line-height: 50px !important;
}
}
#media ( min-width : 767px) {
.nav-side-menu .menu-list .menu-content {
display: block;
}
}
body {
margin: 0px;
padding: 0px;
}
Does anybody know what the problem is and how I can fix it?
please leave your valuable answer and comments.
Not sure whether it's correct workaround for your issue, I have added jQuery function to enable the toggle. Let me know if this helps.
$(".collapsed").click(function(){
$($(this).data("target")).toggle('slow');
});
Please find the updated Fiddle for demo.
On my dashboard example I have the bootstrap navbar menu on top of the column_left menu as shown in code preview below
Update: This link has now be updated with new code from my Answer!
Code Preview Click Here
What I am trying to be able to do is have the navbar so its on the edge of the column left side bar and and open and close correct width also.
Currently the menu opens and closes under neath the navbar.
Question: How can I make my navbar so it on the edge of the sidebar
rather than on top and open and close with same width. I have tried to
put the navbar in side the content div but no luck.
HTML
<div id="column-left">
<ul id="menu">
<li>
<i class="fa fa-dashboard fa-fw"></i> <span>Dashboard</span>
</li>
<li>
<i class="fa fa-bar-chart"></i> <span>Single Link</span>
</li>
<li>
<a class="parent"><i class="fa fa-cog fa-fw"></i> <span>Multilevel Menu</span></a>
<ul>
<li>Link 1</li>
<li><a class="parent">Sub Multilevel Menu 1</a>
<ul>
<li>Sub Menu Link 1a</li>
<li>Sub Menu Link 1b</li>
</ul>
</li>
<li><a class="parent">Sub Multilevel Menu 2</a>
<ul>
<li>Sub Menu Link 2a</li>
<li>Sub Menu Link 2b</li>
<li>Sub Menu Link 2c</li>
</ul>
</li>
</ul>
</li><!-- System -->
</ul>
</div>
<div id="content">
<div class="main">
<div class="container-fluid">
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top navbar-shadow">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a type="button" id="button-menu" class="navbar-brand"><i class="fa fa-indent fa-lg"></i></a>
Project name
</div>
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
<a aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider" role="separator"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Default</li>
<li>Static top</li>
<li class="active">Fixed top <span class="sr-only">(current)</span></li>
</ul>
</div><!--/.nav-collapse -->
</nav>
</div>
</div>
</div>
CSS
#import url(//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,greek-ext,vietnamese);
/* Global */
body {
/*height: 100%;*/
margin: 0;
/*min-height: 100% !important;*/
font-family: 'Open Sans', sans-serif;
overflow-x: hidden;
padding-top: 70px;
width: 100%;
background-color: #eee;
}
a,
a:hover,
a:focus {
cursor: pointer;
text-decoration: none;
}
tr:hover a.dashboard-user:after {
font-family: FontAwesome;
content: "\f044";
font-size: 14px;
}
/* fix for bootstrap hidden and visible */
span.hidden-xs, span.hidden-sm, span.hidden-md, span.hidden-lg {
display: inline;
}
/* Layout */
.container-fluid {
padding-left: 20px;
padding-right: 20px;
}
#content {
padding-bottom: 40px;
transition: all 0.3s;
}
/* Column Left */
#column-left {
width: 50px;
min-height: 100%;
background-color: #242424;
top: 0px;
position: fixed;
padding-top: 70px;
z-index: 10;
transition: all 0.3s;
}
#column-left:hover{
width: 250px;
}
#column-left + #content {
margin-left: 50px;
}
#column-left + #content + #footer {
margin-left: 50px;
}
#media (max-width: 767px) {
#column-left {
overflow: hidden;
display: none;
}
#column-left + #content {
margin-left: 0;
}
#column-left + #content + #footer {
margin-left: 0;
}
}
/* Column Left Active */
#column-left.active {
width: 235px;
display: block;
}
#media (min-width: 768px) {
#column-left.active {
overflow: auto;
}
#column-left.active + #content {
margin-left: 235px;
}
#column-left.active + #content + #footer {
margin-left: 235px;
}
}
#media (max-width: 767px) {
#column-left.active + #content {
position: relative;
left: 235px;
}
#column-left.active + #content + #footer {
position: relative;
left: 235px;
}
}
#column-left.active {
width: 235px;
}
#column-left.active #menu li i {
font-size: 14px;
}
#column-left.active #menu > li > a > span {
display: inline;
}
#column-left.active #menu > li > ul {
position: relative;
left: auto;
top: auto;
width: auto;
visibility: visible;
}
/* Top Navbar */
.menu {
background: #eeeeee none repeat scroll 0 0;
}
.navbar {
background-color: #fff !important;
border: 0 none;
border-radius: 0;
color: #666;
margin-bottom: 0;
}
.navbar.navbar-shadow {
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.08), 0 2px 0 0 rgba(0, 0, 0, 0.02);
}
#button-menu {
display: inline-block;
cursor: pointer;
color: #6D6D6D;
}
#media (max-width: 640px) {
.navbar-brand {
font-size: 14px;
padding: 15px 7px;
}
}
.profile {
display: none;
}
#column-left.active .profile {
display: block;
padding-left: 15px;
border-bottom: 1px solid #2d2d2d;
padding-bottom: 25px;
}
.profile .media-left img {
border: 2px solid #888;
border-radius: 50%;
max-width: 40px;
}
/* Sidebar Menu */
#menu,
#menu ul,
#menu li {
padding: 0;
margin: 0;
min-height: 100%;
list-style: none;
}
#menu {
margin-bottom: 25px;
}
#menu > li {
position: relative;
}
#menu li a {
text-decoration: none;
display: block;
padding: 10px;
cursor: pointer;
color: #aaaaaa;
border-bottom: 1px solid #2d2d2d;
}
#menu li a i {
color: rgba(170, 170, 170, 0.7);
font-size: 16px;
}
#menu > li > a {
color: #aaaaaa;
font-size: 14px;
padding-left: 13px;
}
#menu > li > a:hover {
background-color: #444444;
}
#menu > li > a > span {
display: none;
margin-left: 8px;
}
#menu li li a {
border-bottom: none !important;
}
#menu li li a:hover {
color: #aaaaaa;
background-color: #1e1e1e;
}
/*
#menu li li a:before {
content: "\f101";
font-size: 14px;
font-family: FontAwesome;
margin-left: 10px;
margin-right: 10px;
transition: margin ease 0.5s;
}
*/
#menu li li a:hover:before {
margin-right: 20px;
}
#menu > li.active > a {
color: #aaaaaa;
background: #242424;
}
#menu li.active li a {
color: #aaaaaa;
}
#menu li li.active > a:last-child {
color: #aaaaaa;
}
#menu li li.active a:last-child:before {
margin-left: 20px;
margin-right: 10px;
}
#menu > li > ul {
position: absolute;
left: 50px;
top: 0px;
width: 210px;
background-color: #313131;
visibility: hidden;
}
#menu li ul {
overflow: hidden;
}
#menu li li a.parent:after, #column-left.active #menu > li a.parent:after {
font-family: FontAwesome;
content: "\f105";
float: right;
margin-right: 8px;
}
#menu li li.open > a.parent:after, #column-left.active #menu > li.open > a.parent:after {
font-family: FontAwesome;
content: "\f107";
float: right;
margin-right: 8px;
}
#menu li ul a {
padding-left: 20px;
}
#menu li li ul a {
padding-left: 40px;
}
#menu li li li ul a {
padding-left: 60px;
}
#menu li li li li ul a {
padding-left: 60px;
}
#menu li li li a.parent:after, #column-left.active #menu > li a.parent:after {
font-family: FontAwesome;
content: "\f105";
float: right;
margin-right: 8px;
}
#menu li li li.open > a.parent:after, #column-left.active #menu > li.open > a.parent:after {
font-family: FontAwesome;
content: "\f107";
float: right;
margin-right: 8px;
}
#menu li ul li a.parent:after, #column-left.active #menu > li ul li a.parent:after {
font-family: FontAwesome;
content: "\f105";
float: right;
margin-right: 8px;
}
#menu li ul li.open > a.parent:after, #column-left.active #menu > li ul li.open > a.parent:after {
font-family: FontAwesome;
content: "\f107";
float: right;
margin-right: 8px;
}
Problem solved.
Updated codepen preview
Click Here For Preview
The issue was have the navbar fixed so was on top all the time.
I have removed navbar-fixed-topand removed the padding-top 70px from body {}
Image
CSS
#import url(//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,greek-ext,vietnamese);
body {
margin: 0;
font-family: 'Open Sans', sans-serif;
overflow-x: hidden;
width: 100%;
background-color: #eee;
}
a,
a:hover,
a:focus {
cursor: pointer;
text-decoration: none;
}
tr:hover a.dashboard-user:after {
font-family: FontAwesome;
content: "\f044";
font-size: 14px;
}
/* fix for bootstrap hidden and visible */
span.hidden-xs, span.hidden-sm, span.hidden-md, span.hidden-lg {
display: inline;
}
/* Layout */
.container-fluid {
padding-left: 20px;
padding-right: 20px;
}
#content {
padding-bottom: 40px;
transition: all 0.3s;
}
/* Column Left */
#column-left {
width: 50px;
min-height: 100%;
background-color: #242424;
top: 0px;
position: fixed;
padding-top: 70px;
z-index: 10;
transition: all 0.3s;
}
#column-left:hover{
width: 250px;
}
#column-left + #content {
margin-left: 50px;
}
#column-left + #content + #footer {
margin-left: 50px;
}
#media (max-width: 767px) {
#column-left {
overflow: hidden;
display: none;
}
#column-left + #content {
margin-left: 0;
}
#column-left + #content + #footer {
margin-left: 0;
}
}
/* Column Left Active */
#column-left.active {
width: 235px;
display: block;
}
#media (min-width: 768px) {
#column-left.active {
overflow: auto;
}
#column-left.active + #content {
margin-left: 235px;
}
#column-left.active + #content + #footer {
margin-left: 235px;
}
}
#media (max-width: 767px) {
#column-left.active + #content {
position: relative;
left: 235px;
}
#column-left.active + #content + #footer {
position: relative;
left: 235px;
}
}
#column-left.active {
width: 235px;
}
#column-left.active #menu li i {
font-size: 14px;
}
#column-left.active #menu > li > a > span {
display: inline;
}
#column-left.active #menu > li > ul {
position: relative;
left: auto;
top: auto;
width: auto;
visibility: visible;
}
/* Top Navbar */
.menu {
background: #eeeeee none repeat scroll 0 0;
}
.navbar {
background-color: #fff !important;
border: 0 none;
border-radius: 0;
color: #666;
margin-bottom: 0;
}
.navbar.navbar-shadow {
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.08), 0 2px 0 0 rgba(0, 0, 0, 0.02);
}
#button-menu {
display: inline-block;
cursor: pointer;
color: #6D6D6D;
}
#media (max-width: 640px) {
.navbar-brand {
font-size: 14px;
padding: 15px 7px;
}
}
.profile {
display: none;
}
#column-left.active .profile {
display: block;
padding-left: 15px;
border-bottom: 1px solid #2d2d2d;
padding-bottom: 25px;
}
.profile .media-left img {
border: 2px solid #888;
border-radius: 50%;
max-width: 40px;
}
/* Sidebar Menu */
#menu,
#menu ul,
#menu li {
padding: 0;
margin: 0;
min-height: 100%;
list-style: none;
}
#menu {
margin-bottom: 25px;
}
#menu > li {
position: relative;
}
#menu li a {
text-decoration: none;
display: block;
padding: 10px;
cursor: pointer;
color: #aaaaaa;
border-bottom: 1px solid #2d2d2d;
}
#menu li a i {
color: rgba(170, 170, 170, 0.7);
font-size: 16px;
}
#menu > li > a {
color: #aaaaaa;
font-size: 14px;
padding-left: 13px;
}
#menu > li > a:hover {
background-color: #444444;
}
#menu > li > a > span {
display: none;
margin-left: 8px;
}
#menu li li a {
border-bottom: none !important;
}
#menu li li a:hover {
color: #aaaaaa;
background-color: #1e1e1e;
}
/*
#menu li li a:before {
content: "\f101";
font-size: 14px;
font-family: FontAwesome;
margin-left: 10px;
margin-right: 10px;
transition: margin ease 0.5s;
}
*/
#menu li li a:hover:before {
margin-right: 20px;
}
#menu > li.active > a {
color: #aaaaaa;
background: #242424;
}
#menu li.active li a {
color: #aaaaaa;
}
#menu li li.active > a:last-child {
color: #aaaaaa;
}
#menu li li.active a:last-child:before {
margin-left: 20px;
margin-right: 10px;
}
#menu > li > ul {
position: absolute;
left: 50px;
top: 0px;
width: 210px;
background-color: #313131;
visibility: hidden;
}
#menu li ul {
overflow: hidden;
}
#menu li li a.parent:after, #column-left.active #menu > li a.parent:after {
font-family: FontAwesome;
content: "\f105";
float: right;
margin-right: 8px;
}
#menu li li.open > a.parent:after, #column-left.active #menu > li.open > a.parent:after {
font-family: FontAwesome;
content: "\f107";
float: right;
margin-right: 8px;
}
#menu li ul a {
padding-left: 20px;
}
#menu li li ul a {
padding-left: 40px;
}
#menu li li li ul a {
padding-left: 60px;
}
#menu li li li li ul a {
padding-left: 60px;
}
#menu li li li a.parent:after, #column-left.active #menu > li a.parent:after {
font-family: FontAwesome;
content: "\f105";
float: right;
margin-right: 8px;
}
#menu li li li.open > a.parent:after, #column-left.active #menu > li.open > a.parent:after {
font-family: FontAwesome;
content: "\f107";
float: right;
margin-right: 8px;
}
#menu li ul li a.parent:after, #column-left.active #menu > li ul li a.parent:after {
font-family: FontAwesome;
content: "\f105";
float: right;
margin-right: 8px;
}
#menu li ul li.open > a.parent:after, #column-left.active #menu > li ul li.open > a.parent:after {
font-family: FontAwesome;
content: "\f107";
float: right;
margin-right: 8px;
}
HTML
<div id="column-left">
<ul id="menu">
<li>
<i class="fa fa-dashboard fa-fw"></i> <span>Dashboard</span>
</li>
<li>
<i class="fa fa-bar-chart"></i> <span>Single Link</span>
</li>
<li>
<a class="parent"><i class="fa fa-cog fa-fw"></i> <span>Multilevel Menu</span></a>
<ul>
<li>Link 1</li>
<li><a class="parent">Sub Multilevel Menu 1</a>
<ul>
<li>Sub Menu Link 1a</li>
<li>Sub Menu Link 1b</li>
</ul>
</li>
<li><a class="parent">Sub Multilevel Menu 2</a>
<ul>
<li>Sub Menu Link 2a</li>
<li>Sub Menu Link 2b</li>
<li>Sub Menu Link 2c</li>
</ul>
</li>
</ul>
</li><!-- System -->
</ul>
</div>
<div id="content">
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-shadow">
<div class="container-fluid">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a type="button" id="button-menu" class="navbar-brand"><i class="fa fa-indent fa-lg"></i></a>
Project name
</div>
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
<a aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider" role="separator"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Default</li>
<li>Static top</li>
<li class="active">Fixed top <span class="sr-only">(current)</span></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container-fluid">
</div>
</div>
</div>
I have a dropdown menu that is generated from WordPress so I do not want to change the HTML of it. i can change the CSS as needed though and I pretty much have ot working as I need it with the exception of an alignment issue with my dropdown menu.
Google Chrome
FireFox
Internet Explorer
From the images above you can see that IE and FIreFox display it the same but Chrome is always different from the 2. My Goal is to get this box to align perfectly with the right of the menu button and then get it to look that way in all 3 of these browsers.
I have extracted the HTML and CSS into a JSFiddle page for testing and playing around with here...
Code View: http://jsfiddle.net/jasondavis/hAb4k/
Full View for viewing the menu: http://jsfiddle.net/jasondavis/hAb4k/embedded/result/
My HTML
<nav id="head-nav-menu" class="nav-main" role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
<ul id="nav" class="nav nav-pills">
<li class="active menu-home">
Home
</li>
<li class="menu-about">
About
</li>
<li class="menu-projects">
Projects
</li>
<li class="menu-blog">
Blog
</li>
<li class="dropdown menu-services">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="/services/">Services <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="menu-consulting">Consulting</li>
<li class="menu-magento-development">
Magento Development
</li>
<li class="menu-wordpress-development">
WordPress Development
</li>
<li class="menu-sugarcrm-development">
SugarCRM Development
</li>
<li class="menu-web-development">
Web Development
</li>
<li class="menu-seo">
SEO
</li>
</ul>
</li>
<li class="menu-contact">
Contact
</li>
</ul>
</nav>
CSS
body{
background: #40C8F4 !important;
}
nav ul, nav ol {
list-style: none;
list-style-image: none;
}
#head-nav-menu{
float: right;
margin-top: 29px;
}
#head-nav-menu li {
float: left;
position: relative;
padding: 0 2px 0 2px;
}
.nav a {
font-family: 'arial';
font-size: 18px;
padding: 8px 18px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
white-space: nowrap;
color: #fff;
opacity: 0.9;
letter-spacing: 1px;
text-decoration: none;
}
.menu-contact a {
border: 2px solid #FFF;
padding: 8px 18px;
transition: 0.05s linear;
-moz-transition: 0.05s linear;
-webkit-transition: 0.05s linear;
}
.nav .menu-contact a:hover {
background-color: #FFF;
color: #797979;
}
#nav ul a {
font-weight: 100;
}
.nav a:hover,
.nav > .active a {
opacity: 1;
background-color: #3DBCE6;
}
.nav > .active li a {
background-color: inherit;
}
.tinynav {
display: none;
width: 100%;
margin-top: .5em;
margin-bottom: .6em;
}
.nav li.button a {
background-color: rgba(255, 255, 255, 0.1);
border: 2px solid #FFF;
border-radius: 4px;
margin-top: 5px;
padding: 8px 18px;
font-family: 'ProximaNova-bold', Helvetica, Arial, sans-serif;
font-weight: normal;
margin-left: 16px;
color: #FFF !important;
}
.nav li.button a:hover {
background-color: #FFF;
opacity: 1;
color: #444 !important;
}
/* ==========================================================================
Main Container General Layout Styles
========================================================================== */
.header-container header {
padding-top: 13px;
padding-bottom: 18px;
}
/* Navigation > Dropdown Menus */
#nav .dropdown-menu,
#nav .children {
display: none;
padding: 0;
position: absolute;
z-index: 99999;
border: 1px solid #86DEFC;
width: 333%;
/*right: 8px;*/
left: -239%;
top: 23px;
background-color: #F2F9FC;
}
#nav .dropdown-menu li {
width: 195px;
float: left;
display: inline-block;
/*width: 50%;*/
}
.nav .dropdown-menu a {
color: #030303;
}
#nav li:hover > ul,
#nav ul li:hover > ul,
.dropdown:hover > ul {
display: inline-block;
-webkit-animation: fadeDown 250ms ease;
-moz-animation: fadeDown 250ms ease;
-ms-animation: fadeDown 250ms ease;
-o-animation: fadeDown 250ms ease;
animation: fadeDown 250ms ease;
background-color: #fff;
color: #000;
border: 1px solid #E9E9E9;
border-top: none;
}
#nav .dropdown-menu ul,
#nav .children ul {
left: 99.75%;
top: -1px;
}
#nav ul li,
#nav ul ul li {
margin-left: 0;
}
#nav ul li:first-child,
#nav ul ul li:first-child {
border-top: none;
}
#nav ul a,
#nav ul ul a {
font-size: 14px;
line-height: 21px;
text-align: left;
padding: 10px;
display: inline-block;
min-width: 125px;
border-bottom: none;
margin-bottom: 0 !important;
width: 100%;
letter-spacing: 1px;
font-family: arial;
}
#nav ul a:hover,
#nav ul ul a:hover {
color: #098EB9 !important;
background: none;
}
#nav ul ul.dropdown-menu a:hover {
width: 100%;
color: #63E924 !important;
border-bottom: none;
}
#nav li.current_page_item ul a,
#nav li.current-menu-parent ul a,
#nav li.current_page_parent ul a {
color: #000;
font-weight: 700;
}
#nav ul li.current-menu-item a {
color: #e9242e !important;
}
#head-nav-menu .nav li:hover a.dropdown-toggle {
background: #fff;
color: #000;
opacity: 1;
border-right: 1px solid #E7E7E7;
}
.nav .dropdown a:hover {
opacity: 1;
background-color: #fff;
}
#nav .dropdown-menu li:hover {
background: #F8F8F8;
}
Give display: block to .nav a
then remove left: 239% of #nav .dropdown-menu and give right: 2px and top: 38px to it.
Here is the edited demo for it.
http://jsfiddle.net/hAb4k/3/
I cannot get the z-index to show my drop down menu above my main hero image on the homepage.
The site to visit to see it is: auldlangsynegoods.com. I am hoping somebody can use some dev tools to look at the site and figure out why this drop down isn't appearing.
Here is the clean and simple html:
<nav id="mainNav" role="navigation" class="cf">
<h2>Site navigation</h2>
<ul class="topMenu">
<li class="hover">
<h3>Infant and Baby</h3>
<ul class="subMenu">
<li>Shoes</li>
<li>Hats</li>
<li>Clothing</li>
</ul>
</li>
<li>Millinery</li>
<li class="hover">
<h3>Shoes and Accessories</h3>
<ul class="subMenu">
<li>Mens Shoes</li>
<li>Womens Shoes</li>
<li>Bags</li>
</ul>
</li>
<li class="hover">
<h3>Organic Skincare</h3>
<ul class="subMenu">
<li>Body</li>
<li>Face</li>
</ul>
</li>
<li>Garments</li>
</ul>
</nav>
And here is the simple clean CSS for the desktop view:
/*nav styles*/
#mainNav {
padding-left:3.9%;
margin-bottom: 1.5em;
}
#mainNav li {
float: left;
}
#mainNav a {
display: block;
color: #383420;
border: none;
}
#mainNav a:hover {
color: #484329;
}
#mainNav a.current {
color: #A6A6A6;
cursor: default;
}
/*nav styles*/
#mainNav {
padding-left: 3.9%;
margin-bottom:1em;
}
#mainNav li {
margin-right: 3%;
position: relative;
}
#mainNav a, #mainNav h3 {
font-size: 1.2em;
text-align: left;
padding: 0 1em;
}
/*dropdown menu styles*/
#mainNav ul.subMenu {
float: none;
width: auto;
height: auto;
position: absolute;
top: 0;
padding-top: 2.8em;
left: -8000em;
max-height: 0;
-moz-transition:max-height 0.5s ease;
-webkit-transition:max-height 0.5s ease;
-o-transition:max-height 0.5s ease;
transition:max-height 0.5s ease;
overflow: hidden;
z-index: 5;
}
#mainNav ul.subMenu li {
float: none;
margin: 0;
background: rgb(76, 67, 65);
background: rgba(76, 67, 65, .9);
}
#mainNav li:hover ul {
left: 0;
max-height: 20em;
}
#mainNav ul.subMenu li a {
border-bottom: 1px solid white;
padding: .2em 1em;
white-space: nowrap;
color: white;
text-align: left;
font-size: 1.1em;
}
#mainNav ul.subMenu li:last-child a {
border-bottom: none;
}
#mainNav ul.subMenu li a:hover {
background: rgb(123, 121, 143);
}
On the website you provided it looks to be that z-index isn't the issue, but rather that you need to remove overflow: hidden; from:
#mainNav {
overflow: hidden;
margin-bottom: 1.5em;
}
I was able to see the drop downs after removing that style using the chrome web dev tools.