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
Related
I am attempting a 2 tier drop down menu. I believe I have everything in place but am not getting the drop down. also the :: after is showing pink in notepad ++. is that correct? Ultimately im trying to achieve 5 horizontal menus with the final actually having a vertical 4 drop down nav menu.
</header>
<nav id="nav_menu">
<ul>
<li>Home</li>
<li>Speakers</li>
<li>Luncheons</li>
<li>Get Tickets</li>
<li class="lastitem">About Us
<ul>
<li>Our History</li>
<li>Board of Directors</li>
<li>Past Speakers</li>
<li>Contact Information</li>
</ul>
</li>
</ul>
</nav>
AND THEN THE CSS BELOW. I am confident that the html is correct I believe my trouble is in the CSS..
#nav_menu ul{
list-style-type: none;
position: realative;}
#nav_menu ul li {float: left;}
#nav_menu ul ul {
display: none;
position: absolute;
top: 100%;
}
#nav_menu ul ul li{float: none;}
#nav_menu ul li:hover > ul{
display: block; }
#nav_menu > ul::after{
content: "";
display: block;
clear: both;}
#nav_menu ul li a {
text-align: center;
display: block;
width: 160px;
padding: 1em 0;
text-decoration: none;
background-color: #800000;
color: white;
font-weight: bold;}
#nav_menu ul li a.lastitem{border-right:none;}
#nav_menu ul li a.current {color: yellow;}
I did some cleanup in your code and the main problem was the typo in position: relative; on the #nav_menu ul element. Therefore the dropdown was out of the visible screen. See the working example below.
#nav_menu ul{
list-style-type: none;
position: relative;
}
#nav_menu ul li {
float: left;
}
#nav_menu ul ul {
display: none;
position: absolute;
top: 100%;
}
#nav_menu ul ul li{
float: none;
}
#nav_menu ul li:hover > ul {
display: block;
}
#nav_menu > ul::after{
content: "";
display: block;
clear: both;
}
#nav_menu ul li a {
text-align: center;
display: block;
width: 160px;
padding: 1em 0;
text-decoration: none;
background-color: #800000;
color: white;
font-weight: bold;
}
#nav_menu ul li a.lastitem{
border-right:none;
}
#nav_menu ul li a.current {
color: yellow;
}
<nav id="nav_menu">
<ul>
<li>Home</li>
<li>Speakers</li>
<li>Luncheons</li>
<li>Get Tickets</li>
<li class="lastitem">About Us
<ul>
<li>Our History</li>
<li>Board of Directors</li>
<li>Past Speakers</li>
<li>Contact Information</li>
</ul>
</li>
</ul>
</nav>
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.
I'm new to this - sorry if this is a silly problem. When I hover over the dropdown menu options, the submenu appears, but the background of the submenu has a width of 100%, like the main menu. How can I alter it so that the submenu has a width only of, say, the tab it originates from?
Also, apologies for messy coding. I was playing around with jquery so there are some unnecessary tags in there...
Here is the CSS code:
#menu {
float:left;
width:100%;
background-color:#f23918;
overflow:hidden;
position:relative;
}
#menu ul {
clear:left;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
left:50%;
text-align:center;
}
ul li {
display:block;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
right:50%;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
font-weight: bold;
color: #ffffff;
white-space: nowrap;
background-color: #f23918;
text-align: center;
padding: 10px;
text-transform: uppercase;
}
ul li a:hover {
background: #f29c18;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li { /*Controls dropdowns*/
float: none;
font-size: 11px;
}
li:hover a { background: #f23918;
}
li:hover li a:hover
{
background: #f29c18;
}
and Here is the HTML code:
<div id="menu">
<ul id="navbar">
<li class="active"><span>Home</span></li>
<li class="has-sub"><span>Alpaca Wool Products</span>
<ul class="submenu">
<li><span>Fur Hats</span></li>
<li><span>Capes</span></li>
<li><span>Ponchos</span></li>
<li><span>Shawls</span></li>
<li class="last"><span>Scarves</span></li>
</ul>
</li>
<li class="has-sub"><span>Home Décor</span>
<ul class="submenu">
<li><span>Rugs</span></li>
<li><span>Tapestries</span></li>
<li><span>Throws</span></li>
<li><span>Upholstery</span></li>
<li class="last"><span>Teddy Bears</span></li>
</ul>
</li>
<li><span>About Us</span></li>
<li class="last"><span>Artisans</span></li>
</ul>
</div>
Ok. Here a workout. There might better solution exists.
First you need to give a fixed height to div#menu. Also I dont think you need a float there. Remove overflow hidden and position relative.
#menu {
width:100%;
background-color:#f23918;
height: 38px;
}
Then for submenu add following
li ul {
display: none;
min-width: 100%;
white-space: nowrap;
}
Last solution actually credited to https://stackoverflow.com/a/13775531/2120162
Here you can find how it looks. https://jsfiddle.net/theprog/3h8wpx97/1/
Update: Fixed moving part. Thanks #dowomenfart
li ul {
display: none;
min-width: 100%;
white-space: nowrap;
position:absolute !important;
z-index: 100;
}
Rather than tweaking your code I rewrote a simplified version based on what you need.
$(document).ready(function () {
$("#navbar > li").mouseover(function () {
if (!$(this).hasClass("active")) {
$(this).addClass("active");
$(this).mouseout(function () {
$(this).removeClass("active");
});
}
});
});
#navbar {
background: #f23918;
padding: 0;
margin: 0;
font-size: 0; /*fix inline block gap*/
}
#navbar > li {
font-size: 16px;
list-style: none;
position: relative;
display: inline-block;
padding: 0;
margin: 0;
}
#navbar > li > a {
text-transform: uppercase;
text-decoration: none;
font-size: 16px;
font-weight: bold;
padding: 10px;
display: block;
color: #fff;
}
#navbar > li > a:hover,
#navbar > li.active > a,
#navbar > li > ul {
background: #f29c18;
}
#navbar > li > ul {
display: none;
white-space: nowrap;
padding: 0 0 5px;
margin: 0;
position: absolute;
left: 0;
top: 36px;
}
#navbar > li > ul > li {
display: block;
margin: 10px 20px;
padding: 0;
}
#navbar > li > ul > li > a {
color: #fff;
}
#navbar > li:hover > ul {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<ul id="navbar">
<li>
Item A
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
</ul>
</li>
<li>
Item B
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
</ul>
</li>
<li class="active">
Item C
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
</ul>
</li>
<li>
Item D NoSub
</li>
</ul>
I have a menu like :
<ul id="nav">
<li><span>First link</span>
<ul class="extlang2">
<li class="extli"><span>A</span>
<ul class="extlang2">
<li class="extli"><span>C</span></li>
<li class="extli"><span>D</span></li>
<li class="extli"><span>E</span>
<ul class="extlang2">
<li class="extli"><span>F</span></li>
<li class="extli"><span>G</span></li>
<li class="extli"><span>H</span></li>
<li class="extli"><span>I</span></li>
<li class="extli"><span>J</span></li>
<li class="extli"><span>K</span></li>
<li class="extli"><span>L</span></li>
<li class="extli"><span>M</span></li>
</ul>
</li>
<li class="extli"><span>F</span></li>
<li class="extli"><span>G</span></li>
<li class="extli"><span>H</span></li>
<li class="extli"><span>I</span></li>
<li class="extli"><span>J</span></li>
<li class="extli"><span>K</span></li>
<li class="extli"><span>L</span></li>
<li class="extli"><span>M</span></li>
</ul>
</li>
<li class="extli"><span>B</span></li>
<li class="extli"><span>C</span></li>
<li class="extli"><span>D</span></li>
<li class="extli"><span>E</span></li>
<li class="extli"><span>F</span></li>
<li class="extli"><span>G</span></li>
<li class="extli"><span>H</span></li>
<li class="extli"><span>I</span></li>
<li class="extli"><span>J</span></li>
<li class="extli"><span>K</span></li>
<li class="extli"><span>L</span></li>
<li class="extli"><span>M</span></li>
<li class="extli"><span>N</span></li>
<li class="extli"><span>O</span></li>
<li class="extli"><span>P</span></li>
<li class="extli"><span>Q</span></li>
<li class="extli"><span>R</span></li>
<li class="extli"><span>S</span></li>
<li class="extli"><span>T</span></li>
<li class="extli"><span>U</span></li>
<li class="extli"><span>V</span></li>
<li class="extli"><span>W</span></li>
<li class="extli"><span>X</span></li>
<li class="extli"><span>Y</span></li>
<li class="extli"><span>Z</span></li>
</ul>
</li>
<li><span>Second link</span>
<li><span>Third link</span>
</ul>
How can I show the menu and submenu (which will be open by li:hover) like the picture?
[I used float:left for l but the menu items were shown like 'A B C D E F' etc. but not like the picture]
edit :
my css (sorry,my css is messed up which didn't fulfil my requirement, as you see its not like the picture)
<style type="text/css">
#nav{
list-style-type:none;
}
#nav li {
margin: 0 5px;
padding: 0 0 8px;
position: relative;
list-style: none;
}
/* main level link */
#nav a,
#nav ul li:hover a,
#nav li:hover li a{
text-decoration:none;
color:#ddd;
font-weight:bold;
font-size:13px;
font-family:Arial;
line-height:55px;
height:55px;
width: 139px;
display:block;
}
#nav a span{
position:relative;
margin-right:30px;
}
#nav li:hover > a:first-child,
#nav a:hover,
#nav ul a:hover{
font-weight:bold;
color:#ff0000;
text-decoration:none;
background-color:#fff;
}
#nav li:hover > ul {
display: block;
}
/* level 2 list */
#nav ul {
display: none;
margin: 0;
padding: 0;
position: absolute;
border:1px dotted #eee;
bottom:0px;
left: -139px;
}
#nav ul li {
float: none;
margin: 0;
padding: 0;
}
#nav ul a {
font-weight: normal;
text-shadow: 0 1px 0 #fff;
}
#nav ul li a{
text-align:center !important;
}
#nav ul li a span{
margin:0px auto !important;
}
/* level 3+ list */
#nav ul ul {
left: -139px;
bottom:0px;
border:1px dotted #eee;
}
/* -------------extension area------- */
.extli{
float:left !important;
.extlang2 a{
overflow:hidden;
}
</style>
http://jsfiddle.net/6yQkF/
ul li {
float:left;
width: 100px;
}
ul ul {
display: none;
}
ul li:hover > ul {
display: block;
}
li {
border:1px solid #000;
background:#F00;
list-style:none;
}
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/