I have a menu bar which has 8 to 9 menus horizontally of different character length.
Also, each and every menu has sub menus of different character length.
All I want is -
1. all the menus should be across the page (should fill the html body width that i have decided)
2. all the sub menus should be drop down and will be of same width like as the parent menu width.
All i can do is, i have stretched menu bar so that it can fill the html body width and they took symmetrical width. but i cannot make the sub menus to be drop down one after another.
I have also attched examplary pictures of what i want
HTML
<div id="header_menu">
<ul >
<li>Product Repository
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>File Upload</li>
</ul>
</li>
<li>Inventory Inspection
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>Reprint</li>
<li>Inventory Report</li>
</ul>
</li>
<li>Reports
<ul>
<li>Insert</li>
<li>Search & Edit</li>
</ul>
</li>
</ul>
</div>
CSS
body
{
width: 80%;
margin-left: auto;
margin-right: auto;
text-align:center;
}
HTML is already provided. i'm providing the working CSS for me. hope
it else somebody else.
#header_menu {
height: 10%;
margin-bottom: 2px;
width: 100%;
}
#header_menu ul li ul {
position: absolute;
float: left;
}
#header_menu ul {
margin: 0px;
padding: 0px;
list-style-type: none;
display: table;
width: 100%;
height: 10%;
position: relative;
z-index: 597;
}
#header_menu ul li ul li a {
visibility: hidden;
height: 0px;
width: 100%;
}
#header_menu ul li:hover ul li a {
height: 10%;
visibility: visible;
width: 100%;
}
#header_menu ul li {
position: relative;
display: table-cell;
list-style-type: none;
}
#header_menu ul li a {
display: block;
color: #FFF;
text-decoration: none;
background-color: #333;
font-family: Meiryo, "Meiryo UI", "Microsoft Sans Serif", "MS Outlook";
font-weight: lighter;
font-size: 12px;
border-right-width: thin;
border-bottom-width: thin;
border-right-style: inset;
border-bottom-style: inset;
border-right-color: #999;
border-bottom-color: #999;
}
#header_menu ul li ul li {
width: 100%;
float: left;
}
#header_menu ul li a:hover {
font-family: Meiryo, "Meiryo UI", "Microsoft Sans Serif", "MS Outlook";
font-size: 12px;
font-weight: lighter;
background-color: #000;
}
There is jsfiddle example toked from CSS Menu Maker site
I made some little changes to simplify example.
Little update, nothing special
Update (fiddle too):
<div id='cssmenu'>
<ul>
<li>Product Repository
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>File Upload</li>
</ul>
</li>
<li>Inventory Inspection
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>Reprint</li>
<li>Inventory Report</li>
</ul>
</li>
<li>Reports
<ul>
<li>Insert</li>
<li>Search & Edit</li>
</ul>
</li>
</ul>
</div>
and css :
#cssmenu {padding: 0; margin: 0; border: 0;}
#cssmenu ul, #cssmenu li {list-style: none; margin: 0; padding: 0;}
#cssmenu ul {position: relative; z-index: 597; }
#cssmenu ul li { float: left; min-height: 1px; vertical-align: middle; border:solid 1px blue; width:150px;}
#cssmenu ul li.hover,
#cssmenu ul li:hover {position: relative; z-index: 599; cursor: default; background-color:yellow;}
#cssmenu ul ul {visibility: hidden; position: absolute; top: 100%; left: 0; z-index: 598; width: 150px;}
#cssmenu ul ul li {float: none; margin-left:-1px; width:150px; border:solid 1px red;}
#cssmenu ul li:hover > ul { visibility: visible;}
#cssmenu ul ul {bottom: 0; left: 0;}
#cssmenu ul ul {margin-top: 0; }
#cssmenu ul ul li {font-weight: normal;}
#cssmenu a { display: block; /*line-height: 1em;*/ text-decoration: none; }
It's not pretty but You can see the point.
Update (code changed):
#cssmenu
{
padding:0;
margin:0;
display:block;
}
a {text-decoration:none; color:black; width:100%; box-sizing:border-box; display:block;}
#cssmenu ul
{
position:relative;
margin:0;
padding:0;
cursor:default;
display:table;
width:100%;
border:solid 1px gray;
}
#cssmenu ul li, #cssmenu ul li:last-child
{
list-style-type:none;
display:table-cell;
text-align:center;
vertical-align:middle;
padding-top:3px;
padding-bottom:3px;
border-right:solid 1px gray;
margin:0;
position:relative;
}
#cssmenu ul li:last-child {border:none;}
#cssmenu ul li:hover {background-color:yellow;}
#cssmenu ul li:hover > a {color: red;}
#cssmenu ul ul
{
visibility:hidden;
position:absolute;
top:100%;
margin:0;
margin-left:-1px;
z-index:101;
display:block;
}
#cssmenu ul ul li, #cssmenu ul ul li:last-child
{
display:block;
width:100%;
box-sizing:border-box;
border:none;
border-bottom:solid 1px gray;
}
#cssmenu ul ul li:last-child {border:none;}
#cssmenu ul ul li:hover
{
background-color:navy;
}
#cssmenu ul li li:hover > a {color:white;}
#cssmenu ul li:hover > ul {visibility:visible;}
<div id='cssmenu'>
<ul>
<li>Product Repository
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>File Upload</li>
</ul>
</li>
<li>Inventory Inspection
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>Reprint</li>
<li>Inventory Report</li>
</ul>
</li>
<li>Reports
<ul>
<li>Insert</li>
<li>Search & Edit</li>
</ul>
</li>
<li>Product Repository
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>File Upload</li>
</ul>
</li>
<li>Inventory Inspection
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>Reprint</li>
<li>Inventory Report</li>
</ul>
</li>
<li>Reports
<ul>
<li>Insert</li>
<li>Search & Edit</li>
</ul>
</li>
<li>Product Repository
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>File Upload</li>
</ul>
</li>
<li>Inventory Inspection
<ul>
<li>Insert</li>
<li>Search & Edit</li>
<li>Reprint</li>
<li>Inventory Report</li>
</ul>
</li>
<li>Product Repository
<ul>
<li>Insert</li>
<li>Search & Edit</li>
</ul>
</li>
</ul>
</div>
Try this solution, but when You Run code snippet switch it to Full Page. I hope so this is what You want. But, always but, if Your window is too small, You can't avoid item values in two rows.
Related
why Increased Height item Contact when hover on it? how fix it?
This is My code :
ul {
padding: 0;
}
#nav ul {
display: none;
}
#nav li:hover > ul {
display: block;
}
#nav > li {
float: left;
}
#nav li {
list-style: none;
width: 150px;
position: relative;
border: 1px solid red;
box-sizing: border-box;
}
#nav a {
display: block;
background-color: #000;
color: red;
text-decoration: none;
padding: 10px 20px;
text-align: center;
box-sizing: border-box;
border: 2px solid transparent;
}
#nav ul ul {
position: absolute;
left: 150px;
top: 0;
}
#nav li:hover > a {
color: orange;
}
#nav li:hover > a:after {
content:'\25B6';
color: red;
margin-left: 5px;
padding: 0;
}
#nav > li:hover > a:after {
content: '\25BE';
color: red;
margin-left: 5px;
padding: 0;
}
<div id="wrapper">
<ul id="nav">
<li>Home</li>
<li>Products
<ul>
<li>Product 1</li>
<li>Product 2
<ul>
<li>Model 1</li>
<li>Model 2</li>
<li>Model 3</li>
</ul>
</li>
<li>Product 3</li>
</ul>
</li>
<li>Services
<ul>
<li>Service 1</li>
<li>Service 2</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
See This Image :
When you hover over the list items - you're adding an arrow to the anchor tag via generated content.
Thant's what's causing the increase in height.
To fix this - just set position:absolute on the generated content.
ul {
padding: 0;
}
#nav ul {
display: none;
}
#nav li:hover > ul {
display: block;
}
#nav > li {
float: left;
}
#nav li {
list-style: none;
width: 150px;
position: relative;
border: 1px solid red;
box-sizing: border-box;
}
#nav a {
display: block;
background-color: #000;
color: red;
text-decoration: none;
padding: 10px 20px;
text-align: center;
box-sizing: border-box;
border: 2px solid transparent;
}
#nav ul ul {
position: absolute;
left: 150px;
top: 0;
}
#nav li:hover > a {
color: orange;
}
#nav li:hover > a:after {
content:'\25B6';
color: red;
margin-left: 5px;
padding: 0;
position:absolute;
}
#nav > li:hover > a:after {
content: '\25BE';
color: red;
margin-left: 5px;
padding: 0;
}
<div id="wrapper">
<ul id="nav">
<li>Home</li>
<li>Products
<ul>
<li>Product 1</li>
<li>Product 2
<ul>
<li>Model 1</li>
<li>Model 2</li>
<li>Model 3</li>
</ul>
</li>
<li>Product 3</li>
</ul>
</li>
<li>Services
<ul>
<li>Service 1</li>
<li>Service 2</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
Because of
#nav > li:hover > a:after {
content: '\25BE';
}
the height (font size) is to high of this content.
maybe you should try a background-img.
Or position it absolute and the a-tag relative.
Its because of the :after content attribute (#nav > li:hover > a:after) you are adding on hover(the small arrow icon)
To avoid this, applying line-height: 0 is an efficient way of doing it.
#nav > li:hover > a:after {
content: '\25BE';
color: red;
margin-left: 5px;
padding: 0;
line-height: 0; //fix
}
Also you have this code twice, make sure you remove the redundant one.
It simple line height issue.
ul {
padding: 0;
}
#nav ul {
display: none;
}
#nav li:hover > ul {
display: block;
}
#nav > li {
float: left;
}
#nav li {
list-style: none;
width: 150px;
position: relative;
border: 1px solid red;
box-sizing: border-box;
}
#nav a {
display: block;
background-color: #000;
color: red;
text-decoration: none;
padding: 10px 20px;
text-align: center;
box-sizing: border-box;
border: 2px solid transparent;
line-height: 20px;
}
#nav ul ul {
position: absolute;
left: 150px;
top: 0;
}
#nav li:hover > a {
color: orange;
}
#nav li:hover > a:after {
content:'\25B6';
color: red;
margin-left: 5px;
padding: 0;
}
#nav > li:hover > a:after {
content: '\25BE';
color: red;
margin-left: 5px;
padding: 0;
}
<div id="wrapper">
<ul id="nav">
<li>Home</li>
<li>Products
<ul>
<li>Product 1</li>
<li>Product 2
<ul>
<li>Model 1</li>
<li>Model 2</li>
<li>Model 3</li>
</ul>
</li>
<li>Product 3</li>
</ul>
</li>
<li>Services
<ul>
<li>Service 1</li>
<li>Service 2</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
I am trying to make a horizontal menu, with several horizontal submenus. But the code does not work: https://jsfiddle.net/5v9Ljrwy/
I thought #help ul li:hover > li:first-child {position: absolute;display:inline;width: 80%;left:0;} would make the next submenu visible. Any suggestions how to do this?
<html>
<head>
<style>
#help{
overflow:hidden;
text-align:center;
width:80%;
background-color:#0066ff;
}
#help li{
list-style-type:none;
float:left;
padding:5px;
margin:0px;
}
#help li ul {display: none;background-color:#abcdef;}
//#help li:hover ul, #help li.hover ul {position: absolute;display: inline;width: 80%;left:0;}
#help ul li:hover > li:first-child {position: absolute;display:inline;width: 80%;left:0;}
</style>
</head>
<body>
<p id="ShowHelp">I like</p>
<nav id="help">
<ul>
<li>animals
<ul>
<li>Mammals
<ul>
<li>Elephant</li>
<li>Elephant</li>
<li>Elephant</li>
</ul>
</li>
<li>Fish</li>
</ul>
</li>
<li>cars
<ul>
<li>Ferrari</li>
</ul>
</li>
<li>games</li>
<li>other</li>
</ul>
</nav>
</body>
</html>
You can go with:
#help ul li:hover ul {
position: absolute;
display: inline;
width: 80%;
left: 0;
}
But will still need to style positioning of the submenu.
If looking for a clean code to start with, you may want to try:
HTML:
<ul id="nav">
<li>Home</li>
<li>
Products
<ul class="child">
<li>Hard Drives</li>
<li>Monitors</li>
<li>Speakers
<ul class="child">
<li>10 watt</li>
<li>20 watt</li>
<li>30 watt</li>
</ul>
</li>
<li>Random Equipment</li>
</ul>
</li>
<li>
Services
<ul class="child">
<li>Repairs</li>
<li>Installations</li>
<li>Setups</li>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
CSS:
#nav {position: relative;}
#nav li {
list-style:none;
float: left;
}
#nav li a {
display: block;
padding: 8px 12px;
text-decoration: none;
}
#nav li a:hover {
background-color:red;
color:#FFF;
opacity:1;
}
/* Targeting the first level menu */
#nav {
top:150px;
min-width:850px;
background:#fff;
opacity:0.5;
display: block;
height: 34px;
z-index: 100;
position: absolute;
}
#nav > li > a {
}
/* Targeting the second level menu */
#nav li ul {
color: #333;
display: none;
position: absolute;
width:850px;
}
#nav li ul li {
display: inline;
}
#nav li ul li a {
background: #fff;
border: none;
line-height: 34px;
margin: 0;
padding: 0 8px 0 10px;
}
#nav li ul li a:hover {
background-color:red;
color:#FFF;
opacity:1;
}
/* Third level menu */
#nav li ul li ul{
top: 0;
}
ul.child {
background-color:#FFF;
}
/* A class of current will be added via jQuery */
#nav li.current > a {
background: #f7f7f7;
float:left;
}
/* CSS fallback */
#nav li:hover > ul.child {
left:0;
top:34px;
display:inline;
position:absolute;
text-align:left;
}
#nav li:hover > ul.grandchild {
display:block;
}
Codepen example here.
This is the site I'm working on: http://argumentinamerica.com
Here's the filddle for the menu I'm working on: http://jsfiddle.net/Qtfrq/
HTML:
<div id="menu">
<ul id="menu">
<li><span></span>Home</li>
<li class='has-sub'><span></span>Units
<ul>
<li class='has-sub'>Unit 1</li>
<ul class="thirdtier">
<li>Read About It</li>
<li>Write About It</li>
<li>Hear About It</li>
<li>Speak About It</li>
<li>Read About It</li>
<li>Write About It</li>
</ul>
<li class='has-sub'>Unit 2</li>
<li class='has-sub'>Unit 3</li>
<li class='has-sub'>Unit 4</li>
<li class='has-sub'>Unit 5</li>
</ul>
<li><span></span>Teacher Center</li>
<li><span></span>About</li>
<li><span></span>Give 1</li>
</ul>
</div>
CSS:
#menu {
margin: 0; padding: 2px 0px 2px 0px;
list-style-type: none;
height: 2.4em;
}
#menu ul, #menu li, #menu span, #menu a {
margin: 0;
padding: 0;
position: relative;
}
#menu li {
float: left;
width: 20%;
}
#menu a {
display: block;
margin: 1px;
height: 2.4em;
font-size: 10px;
line-height: 2.4em;
text-decoration: none;
text-transform: uppercase;
text-align: center;
background: #ffcc66;
color: #996600;
}
#menu span {
position: absolute; top: 8px; left: 8px;
width: 8px; height: 8px;
background: #ff9933;
}
#menu a:hover {
background: #cc3300;
color: #ffcc66;
}
#menu ul{
list-style-type: none;
}
#menu .has-sub {
z-index: 1;
}
#menu .has-sub:hover > ul {
display: list-item;
}
#menu .has-sub ul {
display: none;
position: absolute;
left:0;
}
#menu .has-sub ul li {
*margin-bottom: -1px;
position: relative;
width: 100%;
height: 2.6em;
line-height: 2.4em;
}
#menu .has-sub ul li a {
background: #ff9944;
font-size: .65em;
color: ffcc66;
}
#menu .has-sub ul li a:hover,
#menu .has-sub ul li:hover > a {
background: #ff6633;
color: 993300;
}
#menu .has-sub {
z-index: 1;
}
#menu .has-sub:hover > ul {
display: list-item;
}
#menu .has-sub .has-sub:hover + ul {
display: list-item;
}
.thirdtier li {
left: 100%;
}
After much trial and error, I figured out how to get the third tier to show up when I hover over the second tier, but when I try to select something in the third tier list, it disappears. I know I'm supposed to apply a hover style to the a element so that it stays "hovered" when you hover over its child element, and I thought I did that, but it isn't working. I'd love some help on this issue.
Try this: http://jsfiddle.net/Qtfrq/2/
Basically a couple of small changes to your HTMl & CSS.
<div id="menu">
<ul id="menu">
<li><span></span>Home</li>
<li class='has-sub'><span></span>Units
<ul>
<li class='has-sub'>Unit 1
<ul class="thirdtier">
<li>Read About It</li>
<li>Write About It</li>
<li>Hear About It</li>
<li>Speak About It</li>
<li>Read About It</li>
<li>Write About It</li>
</ul>
</li>
<li class='has-sub'>Unit 2</li>
<li class='has-sub'>Unit 3</li>
<li class='has-sub'>Unit 4</li>
<li class='has-sub'>Unit 5</li>
</ul>
</li>
<li><span></span>Teacher Center</li>
<li><span></span>About</li>
<li><span></span>Give 1</li>
</ul>
</div>
#menu {
margin: 0; padding: 2px 0px 2px 0px;
list-style-type: none;
height: 2.4em;
}
#menu ul, #menu li, #menu span, #menu a {
margin: 0;
padding: 0;
position: relative;
}
#menu li {
float: left;
width: 20%;
}
#menu a {
display: block;
margin: 1px;
height: 2.4em;
font-size: 10px;
line-height: 2.4em;
text-decoration: none;
text-transform: uppercase;
text-align: center;
background: #ffcc66;
color: #996600;
}
#menu span {
position: absolute; top: 8px; left: 8px;
width: 8px; height: 8px;
background: #ff9933;
}
#menu a:hover {
background: #cc3300;
color: #ffcc66;
}
#menu ul{
list-style-type: none;
}
#menu .has-sub {
z-index: 1;
}
#menu .has-sub:hover > ul {
display: list-item;
}
#menu .has-sub ul {
display: none;
position: absolute;
left:0;
}
#menu .has-sub ul li {
*margin-bottom: -1px;
position: relative;
width: 100%;
height: 2.6em;
line-height: 2.4em;
}
#menu .has-sub ul li a {
background: #ff9944;
font-size: .65em;
color: ffcc66;
}
#menu .has-sub ul li a:hover,
#menu .has-sub ul li:hover > a {
background: #ff6633;
color: 993300;
}
#menu .has-sub {
z-index: 1;
}
#menu .has-sub:hover > ul {
display: list-item;
}
#menu .has-sub > .has-sub:hover + ul {
display: list-item;
}
.thirdtier {
top: 0;
}
.thirdtier li {
left: 100%;
}
A common mistake is to not place the nested UL inside its parent LI (which, by the way, results in invalid HTML). Because those ULs aren't part of the LI with the hover state, they don't maintain visibility.
In this case, your second level works because you aren't closing the LI tags at all. Therefore, the browser takes a guess at where it should close by looking at the next sibling LI.
You'll probably need to rework your CSS, but this is how it should be:
<ul id="menu">
<li><span></span>Home</li>
<li class='has-sub'><span></span>Units
<ul>
<li class='has-sub'>Unit 1
<ul class="thirdtier">
<li>Read About It</li>
<li>Write About It</li>
<li>Hear About It</li>
<li>Speak About It</li>
<li>Read About It</li>
<li>Write About It</li>
</ul>
</li>
<li class='has-sub'>Unit 2</li>
<li class='has-sub'>Unit 3</li>
<li class='has-sub'>Unit 4</li>
<li class='has-sub'>Unit 5</li>
</ul>
</li>
<li><span></span>Teacher Center</li>
<li><span></span>About</li>
<li><span></span>Give 1</li>
</ul>
I have a really simple menu that I'd like to add a drop-down. What do I need to do to add a drop down in here to one of the items?
http://www.cozinhatur.com/teste1/
HTML
<div class="menu">
<div class="search">
<form id="form1" name="form1" method="post" action="">
<label><span>
<input name="q" type="text" class="keywords" id="textfield" maxlength="50" value="Pesquisar..." />
</span>
<input name="b" type="image" src="images/search.gif" class="button" />
</label>
</form>
</div>
<ul>
<li>HOME</li>
<li>QUEM SOMOS</li>
<li>COZINHAS</li>
<li>DIVERSOS</li>
<li>PRODUTOS</li>
<li>CONTACTOS</li>
</ul>
<div class="clr"></div>
</div>
CSS
.menu
{
background:#5d5d5d;
margin:0 auto;
padding:0;
width:942px;
}
.menu ul
{
border:0;
float:left;
list-style:none;
margin:0;
padding:0;
text-align:left;
}
.menu ul li
{
border:0;
float:left;
margin:0;
padding:0 5px 0 0;
}
.menu ul li a
{
color:#fff;
float:left;
font-family:Verdana, Helvetica, Arial, sans-serif;
font-size:11px;
margin:0;
padding:15px;
text-decoration:none;
}
.menu ul li a:hover
{
background:#b57800;
}
.menu ul li a.active
{
background:#1caedd;
}
.menu ul li ul,.menu ul li ul a
{
font-family:Verdana, Helvetica, Arial, sans-serif;
font-size:11px;
}
Have made a simple CSS drop down from your menu. See jsFiddle Demo. Hover over the second and third menu items to see the drop down.
Hoping this will help you to further build to suit your needs.
The code changes....
HTML
<div class="menu">
<ul>
<li>HOME</li>
<li>QUEM SOMOS
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</li>
<li>COZINHAS
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</li>
</li>
<li>DIVERSOS</li>
<li>PRODUTOS</li>
<li>CONTACTOS</li>
</ul>
</div>
CSS
.menu {
background:#5d5d5d;
margin:0 auto;
padding:0;
width:942px;
}
ul {
border:0;
float:left;
list-style:none;
margin:0;
padding:0;
text-align:left;
}
ul li {
display: block;
position: relative;
float: left;
border:0;
float:left;
margin:0;
padding:0 5px 0 0;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #5d5d5d;
margin: 0px;
white-space: nowrap;
}
ul li a.active
{
background:#1caedd;
}
ul li a:hover {
background: #b57800;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a {
background: #5d5d5d;
}
li:hover li a:hover {
background: #b57800;
}
There is a good example here. The main point is when hovered show the sub menu.
http://www.red-team-design.com/css3-dropdown-menu
see this is pure css based dropdown menu:-
HTML
<ul id="menu">
<li>Home</li>
<li>About Us
<ul>
<li>The Team</li>
<li>History</li>
<li>Vision</li>
</ul>
</li>
<li>Products
<ul>
<li>Cozy Couch</li>
<li>Great Table</li>
<li>Small Chair</li>
<li>Shiny Shelf</li>
<li>Invisible Nothing</li>
</ul>
</li>
<li>Contact
<ul>
<li>Online</li>
<li>Right Here</li>
<li>Somewhere Else</li>
</ul>
</li>
</ul>
CSS
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover {
background: #617F8A;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a {
background: #617F8A;
}
li:hover li a:hover {
background: #95A9B1;
}
see the demo:- http://jsfiddle.net/XPE3w/140/
is it possible to keep the position of the 2nd level billboard fixed to the top as opposed to moving down the page on hover?
Code
HTML
<ul id="nav">
<li>STUFF
<ul>
<li>STUFF
<ul>
<li>
<div>LINK LINK ></div>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>
<div>LINK LINK ></div>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>
<div>LINK LINK ></div>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>
<div>LINK LINK ></div>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>
<div>asdasdasd</div>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>
<div>asdasdasd</div>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>
<div>asdasdasd</div>
</li>
</ul>
</li>
</ul>
</li>
<li>STUFF
<ul>
<li>STUFF</li>
<li>STUFF</li>
</ul>
</li>
<li>STUFF
<ul>
<li>STUFF</li>
<li>STUFF</li>
</ul>
</li>
<li>STUFF
<ul>
<li>STUFF</li>
<li>STUFF</li>
</ul>
</li>
<li>STUFF
<ul>
<li>STUFF</li>
<li>STUFF</li>
</ul>
</li>
<li>STUFF
<ul>
<li>STUFF</li>
<li>STUFF</li>
</ul>
</li>
<li class="navblue">STUFF
<ul>
<li>STUFF</li>
<li>STUFF</li>
</ul>
</li>
<li class="navorange">STUFF</li>
</ul>
CSS
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
#nav, #nav ul {
list-style-type: none;
list-style-position: outside;
position: relative;
line-height: 30px;
margin: 0;
padding: 0;
}
#nav li > a {
font-weight: bold;
display: block;
margin-top: -1px;
color: #fff;
text-decoration: none;
background-color: #008000;
padding: 0 10px;
width: 99px;
border-bottom: 1px solid #FFFFFF;
}
#nav li > a:hover {
background-color: #99CC00;
color: #000;
}
#nav li {
float: left;
position: relative;
margin-right: 1px;
}
#nav ul {
position: absolute;
display: none;
width: 12em;
top: 2.5em;
}
#nav li ul a {
width: 160px;
height: auto;
float: left;
line-height: 30px;
font-size: 12px;
font-weight: normal;
}
#nav ul ul {
top: auto;
}
#nav ul ul {
height: 299px;
width: 652px;
margin: 0;
padding: 0;
background-color: #999999;
}
#nav ul ul li {
padding: 20px;
}
#nav li.navblue a {
background-color: #3398CC;
}
#nav li.navorange a {
background-color: #FF9A02;
color: #FEFF00;
}
#nav li ul ul {
left: 14.9em;
margin-left: -2px;
}
#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li:hover ul ul ul ul {
display: none
}
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li li li li:hover ul {
display: block
}
JavaScript/jQuery
window.addEvent('load', function () {
function mainmenu() {
$("#nav ul").css({display:"none"}); // Opera Fix
$("#nav li").hover(function () {
$(this).find('ul:first').css({visibility:"visible", display:"none"}).show(0);
}, function () {
$(this).find('ul:first').css({visibility:"hidden"});
});
}
$(document).ready(function () {
mainmenu();
});
})
Live Example
replace your current css with this:
<style type='text/css'>
body {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000;}
#nav,#nav ul{list-style-type:none;list-style-position:outside;position:relative;line-height:30px;margin:0;padding:0;}
#nav li > a{font-weight:bold;display:block;margin-top:-1px;color:#fff;text-decoration:none;background-color:#008000;padding:0 10px;width:99px;border-bottom:1px solid #FFFFFF;}
#nav li > a:hover{background-color:#99CC00;color:#000;}
#nav li{float:left;margin-right:1px;}
#nav ul{position:absolute;display:none;width:12em;top:2.5em;}
#nav li ul a{width:160px;height:auto;float:left;line-height:30px;font-size:12px;font-weight:normal;}
#nav ul ul{top:0;}
#nav ul ul {height:299px;width:652px;margin:0;padding:0;background-color:#999999;}
#nav ul ul li {padding:20px;}
#nav li.navblue a{background-color:#3398CC;}
#nav li.navorange a{background-color:#FF9A02;color:#FEFF00;}
#nav li ul ul{left:14.9em;margin-left:-2px;}
#nav li:hover ul ul,#nav li:hover ul ul ul,#nav li:hover ul ul ul ul{display:none}
#nav li:hover ul,#nav li li:hover ul,#nav li li li:hover ul,#nav li li li li:hover ul{display:block}
</style>
Changes: remove relative position from #nav li and position #nav ul ul top:0