I'm creating a website, and currently I am having issues with my navigation bar. The issue I am having is with the active link. The background won't fit to the size of the initial button like I want it to. The background is just highlighting the text basically.
<div class="nav">
<ul>
<li>Home</li>
<li><a class="active" href="cage-habitat.html">Cage & Habitat</a>
<ul>
<li>Litter Training</li>
</ul>
</li>
<li>Food & Treats</li>
<li>Dust Bath & Care</li>
<li>Safe Toys</li>
<li>Chinquiry</li>
</ul>
</div>
.nav {
background-color: #526655;
}
.nav a {
color: #fff;
text-decoration: none;
}
.nav ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
.nav ul li {
color: #fff;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #526655;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.nav ul li:hover {
background: #94b399;
color: #fff;
}
/* drop down styles */
.nav ul li ul {
padding: 0;
position: absolute;
top: 42px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
.nav ul li ul li {
background: #94b399;
display: block;
color: #fff;
}
.nav ul li ul li:hover {
background: #94b399;
}
.nav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
/* end dropdown styles */
.active {
background: #94b399;
}
Any help would be appreciated. https://jsfiddle.net/cweav3r/7j25e8jh/
<ul><li><a href="litter-train-chinchilla.html">Litter
Training</a></li></ul> is taking extra space .
DEMO : http://jsfiddle.net/b89kds70/10/
<div class="nav">
<ul>
<li>Home</li>
<li><a class="active" href="cage-habitat.html">Cage & Habitat</a>
</li>
<li>Food & Treats</li>
<li>Dust Bath & Care</li>
<li>Safe Toys</li>
<li>Chinquiry</li>
</ul>
</div>
.nav {
background-color: #526655;
}
.nav a {
color: #fff;
text-decoration: none;
}
.nav ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
position:relative;
}
.nav ul li {
color: #fff;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #526655;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.nav ul li:hover {
background: #94b399;
color: #fff;
}
/* drop down styles */
.nav ul li ul {
padding: 0;
position: relative;
top: 42px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
.nav ul li ul li {
background: #94b399;
display: inline;
color: #fff;
}
.nav ul li ul li:hover {
background: #94b399;
}
.nav ul li:hover ul {
position:absolute;
display: block;
opacity: 1;
visibility: visible;
}
/* end dropdown styles */
Related
my drop-down menu is not showing up. It's completely invisible or is just not working. Nothing happens when I hover over the "Store" tab which is where the drop-down should occur. When I remove "visibility: hidden" to see where the drop-down menu actually is, the drop-down items appear as the first two tabs which are "Home" and "About". So in the place of the Home and About tabs, the drop-down menu items appear instead. Any help would be appreciated.
nav {
background-color: #373945;
border-top: 6px solid #ABACAF;
width: 100%;
height: auto;
margin: 0 auto;
display: block;
position: relative;
float: left;
}
nav ul {
list-style: none;
text-align: center;
width: 100%;
max-width: 960px;
margin: 0 auto;
}
nav ul ul {
padding: 0;
position: absolute;
z-index: 9999;
opacity: 0;
visibility: hidden;
transition: all .25s ease-in;
-o-transition: all .25s ease-in;
-ms-transition: all .25s ease-in;
-moz-transition: all .25s ease-in;
-webkit-transition: all .25s ease-in;
}
nav ul li:hover ul {
display: block;
visibility: visible;
opacity: 1;
}
nav ul li {
background-color: #373945;
width: 12.5%;
height: 2em;
border-right: 1px solid #ABACAF;
display: inline-block;
float: left;
/* Internet Explorer 10 */
display: -ms-flexbox;
-ms-flex-pack: center;
-ms-flex-align: center;
/* Firefox */
display: flex;
justify-content: center;
align-items: center;
/* Safari, Opera, and Chrome */
display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;
/* W3C */
vertical-align: middle;
font-weight: normal;
-webkit-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-moz-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-ms-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-o-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
nav ul li:nth-child(1) { border-left: 1px solid #ABACAF; }
nav ul li:hover { background-color: #544D55; color: white; }
nav ul li a {
color: #ABACAF;
text-decoration: none;
}
nav ul li:hover a { color: white; }
nav li ul li {
font-size: 1.3em !important;
text-align: left;
width: 100%;
display: block;
float: left;
}
nav li ul li:nth-of-type(1) {
width: 96%;
padding: 18px 0 20px 4%;
}
nav li ul li:nth-of-type(2) {
width: 96%;
padding: 18px 0 20px 4%;
}
nav li ul li a {
color: black;
font-size: 2em;
border: none;
display: block;
}
/*Style 'show menu' label button and hide it by default*/
.show-menu {
cursor: pointer;
display: none;
}
/*Hide checkbox*/
input[type=checkbox] { display: none; }
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu { display: block; }
<nav>
<label for="show-menu" class="show-menu"><img src="hamburger-red.png" alt="Hamburger Icon" style="position: relative; top: .25em;"></label>
<input type="checkbox" id="show-menu" role="button">
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Programs</li>
<li>Why Equine</li>
<li>Our Horses</li>
<li>Benefits</li>
<li>Store</li>
<ul class="drop-nav">
<li>Horse Health Store</li>
<li>People Store</li>
</ul>
<li>Contact</li>
</ul>
</nav>
It's not pretty but the dropdown works in the below solution. The issue was the dropdown ul was not nested inside the first-level li.
nav {
background-color: #373945;
border-top: 6px solid #ABACAF;
width: 100%;
height: auto;
margin: 0 auto;
display: block;
position: relative;
float: left;
}
nav ul {
list-style: none;
text-align: center;
width: 100%;
max-width: 960px;
margin: 0 auto;
}
nav ul ul {
padding: 0;
position: absolute;
z-index: 9999;
opacity: 0;
visibility: hidden;
transition: all .25s ease-in;
-o-transition: all .25s ease-in;
-ms-transition: all .25s ease-in;
-moz-transition: all .25s ease-in;
-webkit-transition: all .25s ease-in;
}
nav ul li:hover ul {
display: block;
visibility: visible;
opacity: 1;
}
nav ul li {
background-color: #373945;
width: 12.5%;
height: 2em;
border-right: 1px solid #ABACAF;
display: inline-block;
float: left;
/* Internet Explorer 10 */
display: -ms-flexbox;
-ms-flex-pack: center;
-ms-flex-align: center;
/* Firefox */
display: flex;
justify-content: center;
align-items: center;
/* Safari, Opera, and Chrome */
display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;
/* W3C */
vertical-align: middle;
font-weight: normal;
-webkit-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-moz-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-ms-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-o-transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
transition: background-color 200ms ease-in-out 0s, color 200ms ease-in-out 0ms;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
nav ul li:nth-child(1) { border-left: 1px solid #ABACAF; }
nav ul li:hover { background-color: #544D55; color: white; }
nav ul li a {
color: #ABACAF;
text-decoration: none;
}
nav ul li:hover a { color: white; }
nav li ul li {
font-size: 1.3em !important;
text-align: left;
width: 100%;
display: block;
float: left;
}
nav li ul li:nth-of-type(1) {
width: 96%;
padding: 18px 0 20px 4%;
}
nav li ul li:nth-of-type(2) {
width: 96%;
padding: 18px 0 20px 4%;
}
nav li ul li a {
color: black;
font-size: 2em;
border: none;
display: block;
}
/*Style 'show menu' label button and hide it by default*/
.show-menu {
cursor: pointer;
display: none;
}
/*Hide checkbox*/
input[type=checkbox] { display: none; }
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu { display: block; }
<nav>
<label for="show-menu" class="show-menu"><img src="hamburger-red.png" alt="Hamburger Icon" style="position: relative; top: .25em;"></label>
<input type="checkbox" id="show-menu" role="button">
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Programs</li>
<li>Why Equine</li>
<li>Our Horses</li>
<li>Benefits</li>
<li>Store
<ul class="drop-nav">
<li>Horse Health Store</li>
<li>People Store</li>
</ul></li>
<li>Contact</li>
</ul>
</nav>
To clarify, all I changed was moved the closing </li> tag to wrap around the dropdown ul.
<li>Store
<ul class="drop-nav">
<li>Horse Health Store</li>
<li>People Store</li>
</ul></li>
use this to your hover div overflow to the outside of the body and change your Store li is over after your hover ul complete
nav {
background-color: #373945;
width: 100%;
height: auto;
margin: 0 auto;
display: block;
position: relative;
float: left;
}
nav ul {
list-style: none;
text-align: center;
width: 100%;
max-width: 960px;
margin: 0 auto;
}
nav ul ul {
padding: 0;
position: absolute;
z-index: 9999;
opacity: 0;
visibility: hidden;
}
nav ul li.show:hover>ul {
display: block;
visibility: visible;
opacity: 1;
width: 100%;
max-width: 200px;
top: 32px;
}
nav ul li {
background-color: #373945;
width: 12.5%;
height: 2em;
border-right: 1px solid #ABACAF;
display: inline-block;
float: left;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
}
nav ul li:hover {
background-color: #544D55;
color: white;
}
nav ul li a {
color: #ABACAF;
text-decoration: none;
}
nav ul li:hover a {
color: white;
font-size: 16px;
}
nav li ul li {
font-size: 1.3em !important;
text-align: left;
width: 100%;
display: block;
float: left;
padding: 10px;
}
nav li ul li a {
color: black;
font-size: 2em;
border: none;
display: block;
}
<nav>
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Programs</li>
<li>Why Equine</li>
<li>Our Horses</li>
<li>Benefits</li>
<li class="show">Store
<ul class="drop-nav">
<li>Horse Health Store </li>
<li>People Store</li>
</ul>
</li>
<li>Contact</li>
</ul>
</nav>
I'm trying to make a navigation bar for a hobby website to display my photography and other interest's of mine, I'm having slight issues with the position of a drop-down bar I have.
I wanted to know how I would be able to position the drop down menu so when I hover over the music item it would show directly under it. I tried position: relevant, it did work but it shifted all the items to the left of it down to align with the drop down menu.
http://jsfiddle.net/daCrosby/Ly8wuws1/
body{
background-color: #333;
}
nav ul {
list-style: none;
margin: 10px;
padding: 0;
font-family: 'Roboto', sans-serif;
font-weight: bold;
}
nav li {
display: inline-block;
margin: 0 5px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
nav a {
color: black;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
nav a:hover {
color: #12242d;
}
nav span {
display: block;
color: rgba(255,255,255,0.6);
}
.Inav ul {
list-style: none;
margin-top: 20%;
padding: 0;
text-align: left;
top: 0;
left: 0;
position: fixed;
right: 0;
text-align: center;
font-family: 'Roboto', sans-serif;
font-weight: bold;
}
.Inav nav ul li {
display: inline-block;
margin: 0 5px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.Inav nav a {
color: black;
position: block
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
text-decoration: none;
}
.Inav nav a:hover {
color: #12242d;
}
.Inav nav span {
color: rgba(255,255,255,0.6);
}
.Inav ul li:hover ul{
display: block;
margin: 0px;
padding: 0px;
}
.Inav ul li ul{
display: none;
position: absolute;
}
.Inav ul li ul li{
display: block;
}
.Inav ul ul a{
color: white;
}
<div class="Inav">
<nav>
<ul>
<li><span>Home</span></li>
<li><span>FAQ</span></li>
<li><span>Honesty</span></li>
<li><span>Rand2</span></li>
<li><span>Rand3</span></li>
<li><span>Music</span>
<ul>
<li>Kanye</li>
<li>Drake</li>
</ul>
</li>
</ul>
</nav>
</div>
You need to add position: relevant to the parent list items, then add positioning top and left on the sub menu.
nav li {
position: relative;
}
.Inav ul li ul{
position: absolute;
top: 100%; /* modify as necessary */
left: 0px; /* modify as necessary */
}
http://jsfiddle.net/daCrosby/Ly8wuws1/1/
My problem is that the 3rd menu level is not showing up on the website.
- FISMA and HiPAA are not showing up on my menu. they should be under the Audit and Assessment which is also under Services
/* start h_menu */
.h_menu4 {
float: center;
}
.toggleMenu {
display: none;
background: rgba(29, 82, 99, 0.22);
padding: 10px 15px;
width: 100%;
color: #fff;
}
.nav {
list-style: none;
*zoom: 1;
}
.nav:before,
.nav:after {
content: " ";
display: table;
}
.nav:after {
clear: both;
}
.nav ul {
list-style: none;
width: 9em;
}
.nav li a {
display: block;
padding: 10px 20px 40px 20px;
color: #fff;
font-size: 1em;
}
.nav li {
position: relative;
}
.nav li.active a,
.nav li a:hover {
border-bottom: 10px solid #23aae1;
}
.nav > li {
float: left;
}
.nav > li > a.parent {
background: url(../images/plus.png) no-repeat right top 16px;
}
.nav > li > a:hover {
color: #23aae1;
}
.nav li ul {
position: absolute;
left: -9999px;
}
.nav > li.hover > ul {
left: 0px;
}
.nav li li.hover ul {
left: 100%;
top: 0;
-webkit-transition: background .2s linear;
-moz-transition: background .2s linear;
-ms-transition: background .2s linear;
-o-transition: background .2s linear;
transition: background .2s linear;
}
.nav li li a {
font-size: 0.8725em;
padding: 10px;
display: block;
color: #fff;
background: rgba(73, 93, 137, 0.56);
position: relative;
z-index: 9999;
border-top: 1px solid rgba(233, 233, 233, 0.09);
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
.nav li li li a {
background: #0a2334;
z-index: 200;
border-top: 1px solid #1d7a62;
}
.nav li li a:hover {
background: #041420;
color: #fff;
border-bottom: none;
}
<ul class="nav">
<li>About Us
</li>
<li>Solutions
<ul>
<li>Healthcare IT Solutions
</li>
<li>Government IT Solutions
</li>
</ul>
</li>
<li>Services
<ul>
<li>Risk Management
</li>
<ul>
<li>Cyber Risk & Security Controls Assessment
</li>
<li>CyberSprint Advisory
</li>
</ul>
<li>Audit & Assessment
</li>
<ul>
<li>FISMA
</li>
<li>HIPAA
</li>
</ul>
<li>Disaster Recovery & Business Continuity Planning
</li>
</ul>
</li>
<li>Contact
</li>
</ul>
sorry guys I'm quite new at this and not really used into deep coding. Every help would be much appreciated.
The problem was that <li>Risk Management</li> had to wrap submenu <ul> ... </ul>.
/* start h_menu */
.h_menu4 {
float: center;
}
.toggleMenu {
display: none;
background: rgba(29, 82, 99, 0.22);
padding: 10px 15px;
width: 100%;
color: #fff;
}
.nav {
list-style: none;
*zoom: 1;
}
.nav:before,
.nav:after {
content: " ";
display: table;
}
.nav:after {
clear: both;
}
.nav ul {
list-style: none;
width: 9em;
padding: 0;
}
.nav li a {
display: block;
padding: 10px 20px 40px 20px;
color: #000000;
font-size: 1em;
}
.nav li {
position: relative;
}
.nav li.active a,
.nav > li:hover > a {
border-bottom: 10px solid #23aae1;
}
.nav > li {
float: left;
}
.nav > li > a.parent {
background: url(../images/plus.png) no-repeat right top 16px;
}
.nav > li:hover > a {
color: #23aae1;
}
.nav li ul {
position: absolute;
left: -9999px;
}
.nav > li:hover > ul {
left: 0px;
}
.nav li li:hover ul {
left: 100%;
top: 0;
-webkit-transition: background .2s linear;
-moz-transition: background .2s linear;
-ms-transition: background .2s linear;
-o-transition: background .2s linear;
transition: background .2s linear;
}
.nav li li a {
font-size: 0.8725em;
padding: 10px;
display: block;
color: #fff;
background: rgba(73, 93, 137, 0.56);
position: relative;
z-index: 9999;
border-top: 1px solid rgba(233, 233, 233, 0.09);
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
.nav li li li a {
background: #0a2334;
z-index: 200;
border-top: 1px solid #1d7a62;
}
.nav li li a:hover {
background: #041420;
color: #fff;
border-bottom: none;
}
<ul class="nav">
<li>About Us
</li>
<li>Solutions
<ul>
<li>Healthcare IT Solutions
</li>
<li>Government IT Solutions
</li>
</ul>
</li>
<li>Services
<ul>
<li>Risk Management
<ul>
<li>Cyber Risk & Security Controls Assessment
</li>
<li>CyberSprint Advisory
</li>
</ul>
</li>
<li>Audit & Assessment
</li>
<ul>
<li>FISMA
</li>
<li>HIPAA
</li>
</ul>
<li>Disaster Recovery & Business Continuity Planning
</li>
</ul>
</li>
<li>Contact
</li>
</ul>
I'm trying to create a navbar (already done) with a dropdown, but the dropdown keeps spazzing out when I hover over it :(
I made a JS Fiddle of what I've accomplished so far, and I was hoping for some help!
http://jsfiddle.net/kkpp6/
I think it might be due to the display: none; I used in one of the ul's or possibly due to a stupid typo but I can't figure out where!
As well as this, I can't figure out how to make a sub-menu for my sub-menus that already exist.. (so the desc tab has a submenu of swim squad which will also have a sub-menu of other things).. How would I do that? I can't figure out where I would start!
Cheers for all the help in advance!
Try like this: LINK
CSS:
.nav-wrap {
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar li a {
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
padding: 6px;
font-size: 12px;
text-decoration: none;
text-transform: uppercase;
}
ul.navigation-bar li a:hover {
background-color: #06398F;
}
ul.navigation-bar {
text-align: left;
display: inline;
margin: 0;
list-style: none;
}
ul.navigation-bar li {
line-height:28px;
margin-right: -4px;
position: relative;
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar li ul {
padding: 0;
position: absolute;
top: 28px;
left: 0;
width: 120px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul.navigation-bar li ul li {
background: #125CC1;
display: block;
color: #fff;
}
ul.navigation-bar li ul li:hover {
background: #06398F;
color: #fff;
}
ul.navigation-bar li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
Updated fiddle LINK
Multi-level dropdown menu LINK
On line 38, you set a list to display when the user hovers over a list item. This makes it visible, but also causes the entire menu to shift over so that you're no longer hovering over the list item that triggered that. If you use position:absolute on the list, it won't affect the other elements on the page:
ul.navigation-bar li > ul {
position:absolute;
}
JSFiddle: http://jsfiddle.net/P9SUg/
I also think its because of display:none;, instead of display:none; you should use visibility:hidden;.
and also add
ul.navigation-bar li > ul {
position:absolute;
}
You need to do lot of changes in CSS for making dropdown menu.
.nav-wrap {
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar {
list-style-type: none;
margin: 0;
padding: 0;
}
ul.navigation-bar > li {
display: inline;
position:relative;
}
ul.navigation-bar > li > a {
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
padding: 4px;
font-size: 12px;
text-decoration: none;
text-transform: uppercase;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
ul.navigation-bar > li > a:hover {
background-color: #06398F;
}
ul.navigation-bar ul {
display: none;
}
ul.navigation-bar li:hover > ul {
display: block;
position:absolute;
top:23px;
background-color:#ff00ff;
z-index:10;
width:100%;
list-style-type: none;
margin: 0;
padding: 0;
}
ul.navigation-bar li ul li a
{
list-type:none;
text-align: left;
font-weight:normal;
padding: 4px;
font-size: 10px;
text-decoration: none;
text-transform: uppercase;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
ul.navigation-bar li ul li:hover
{
background-color:#000;
}
ul.navigation-bar li ul li:hover a
{
color:#fff;
}
FIDDLE DEMO
I'm having trouble creating the third level fligh out for a horizontal css menu. I've tried many different changes to the css to no avail. I have included the menu html and the css. What changes do I need to make to the css to have it work?
When 'ADD SCORES' is hovered over the 2 menus should show to the right
#menu {
background-color: #66A366;
padding: 6px 0 6px 20px;
}
#menu ul li a {
color: #fff;
text-decoration: none;
font-family:"Arial Narrow", "Myriad Pro";
}
#menu li {
color: #fff;
text-decoration: none;
font-family:"Arial Narrow", "Myriad Pro";
}
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {
font: bold 14px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #66A366;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
z-index:1000;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover {
background: #666;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
ul li ul li:hover li{
display: block;
opacity: 1;
visibility: visible;
}
ul li ul li ul li{
padding: 15px 20px;
font: bold 14px/18px sans-serif;
display: none;
position: relative;
top: -48px;
left: 154px;
width: 120px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
opacity: 0;
z-index:1000;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
<div id="menu">
<ul>
<li>SCORES
<ul>
<li>ADD SCORES
<ul>
<li>Level 3-A-1</li>
<li>Level 3-A-2</li>
</ul>
</li>
<li>EDIT SCORES</li>
</ul>
</li>
<li>PLAYERS
<ul>
<li>ADD PLAYER</li>
<li>EDIT PLAYERS</li>
</ul>
</li>
<li>COURSES
<ul>
<li>ADD COURSE</li>
<li>EDIT COURSES</li>
</ul>
</li>
<li>ADMIN</li>
</ul>
</div>
Demo FIDDLE
I'm not sure how you want your menu to look like, but I noticed that you forgot to wrap the tabs inside a <ul></ul> tag.
If you do that, the menu will look and behave like what most users would expect.
<div id="menu">
<ul> <-- here
<li>SCORES
// some code
<li>ADMIN</li>
</ul> <-- and here
</div>
You can save your time using Swimbi - Swift Menu Builder
- http://f-source.com/swimbi/
have a look at menu demo