I have a CSS manu that I am using with sub menus. I was wondering how I would go about adding a sub-submenu to it. For example, I hover over the main menu item and the submenu pops up, then I hover over the submenu item and another submenu pops up. Here is the JS Fiddle that I am using now:
http://jsfiddle.net/PrinceofVegas/Dg3yQ/4/
Here is the CSS I am using:
.menu{
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:18px;
font-weight:bold;
}
.menu ul{
background:#006633;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.menu li{
float:left;
padding:0px;
}
.menu li a{
background:#006633 url("../images/seperator.gif") bottom right no-repeat;
color:#ffffff;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
.menu li a:hover, .menu ul li:hover a{
background: #003f20 url("../images/hover.gif") bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
.menu li ul{
background:#006633;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:1em;
/*left:0;*/
}
.menu li:hover ul{
display:block;
}
.menu li li {
background:url('../images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
.menu li:hover li a{
background:none;
}
.menu li ul a{
display:block;
height:30px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul a:hover, .menu li ul li:hover a{
background:#003f20 url('../images/hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
.menu p{
clear:left;
}
Here is the HTML i am using:
<div class="menu">
<ul>
<li><a href="#" target="_self" >Main Item 1</a></li>
<li><a href="#" target="_self" >Main Item 2</a>
<ul>
<li><a href="#" target="_self" >Test Sub Item</a></li>
<li><a href="#" target="_self" >Test Sub Item</a></li>
<li><a href="#" target="_self" >Test Sub Item</a></li>
<li><a href="#" target="_self" >Test Sub Item</a></li>
</ul>
</li>
<li><a href="#" target="_self" >Main Item 3</a></li>
<li><a href="#" target="_self" >Main Item 4</a>
<ul>
<li><a href="#" target="_self" >Test Sub Item</a></li>
<li><a href="#" target="_self" >Test Sub Item</a></li>
<li><a href="#" target="_self" >Test Sub Item</a></li>
</ul>
</li>
</ul>
</div>
Here is how I would approach what you are looking for: http://jsfiddle.net/Dg3yQ/26/
I took some liberties on revising the CSS. The revised CSS reduced the code by a couple hundred characters and I believe it accomplishes what you intended. I hope this helps.
EDITED: Added a streamlined code example with comments to this answer on how these sub menus can be accomplished.
#nav {
list-style:none inside;
margin:0;
padding:0;
text-align:center;
}
#nav li {
display:block;
position:relative;
float:left;
background: #006633; /* menu background color */
}
#nav li a {
display:block;
padding:0;
text-decoration:none;
width:200px; /* this is the width of the menu items */
line-height:35px; /* this is the hieght of the menu items */
color:#ffffff; /* list item font color */
}
#nav li li a {font-size:80%;} /* smaller font size for sub menu items */
#nav li:hover {background:#003f20;} /* highlights current hovered list item and the parent list items when hovering over sub menues */
/*--- Sublist Styles ---*/
#nav ul {
position:absolute;
padding:0;
left:0;
display:none; /* hides sublists */
}
#nav li:hover ul ul {display:none;} /* hides sub-sublists */
#nav li:hover ul {display:block;} /* shows sublist on hover */
#nav li li:hover ul {
display:block; /* shows sub-sublist on hover */
margin-left:200px; /* this should be the same width as the parent list item */
margin-top:-35px; /* aligns top of sub menu with top of list item */
}
<ul id="nav">
<li>Main Item 1</li>
<li>Main Item 2
<ul>
<li>Sub Item</li>
<li>Sub Item</li>
<li>SUB SUB LIST ยป
<ul>
<li>Sub Sub Item 1
<li>Sub Sub Item 2
</ul>
</li>
</ul>
</li>
<li>Main Item 3</li>
</ul>
If you want to use CSS transitions (which won't work on display property), you can replace display with opacity instead. To deal with the fact that elements now take up space even when hidden, you can simply put the whole menu into a separate div that is positioned absolutely and highest in z-order (which a menu ought to be anyway). Then nothing will be in the way as the menu will be the only item in the top layer.
Here is the original example modified by me for CSS transitions:
#menu {
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:18px;
font-weight:bold;
}
#nav {
height:35px;
list-style:none;
margin:0;
padding:0;
float:left;
text-align:center;
}
#nav li {
display:inline-block;
position:relative;
float:left;
background: #006633;
}
#nav li a {
display:inline-block;
width:200px;
line-height:35px;
padding:0;
text-decoration:none;
color:#ffffff;
}
#nav li li {float:left; #006633;}
#nav li li a {
display:block;
font-size:12px;
opacity:1;
transition: opacity 1s;
}
#nav li:hover {background:#003f20;}
/*--- Sublist Styles ---*/
#nav ul {
position:absolute;
padding:0px;
left:0;
/* display:none; */
opacity:0;
transition: opacity 1s;
}
/*--- Hide Sub Sublists ---*/
#nav li:hover ul ul {
/* display:none; */
opacity:0;
transition: opacity 1s;
}
/*--- Sublevel UL's display and position on hover ---*/
#nav li:hover ul {
/* display:block; */
opacity:1;
transition: opacity 1s;
}
/* had to make the position NOT based on hover, but permanent
for the transition to work , thus moved it from POS_001 */
#nav li li ul {
margin-left:200px;
margin-top:-35px;
}
#nav li li:hover ul {
/* POS_001 */
/* display:block; */
opacity:1;
transition: opacity 1s;
}
<div id="menu">
<ul id="nav">
<li><a href="#" target="_self" >Main Item 1</a></li>
<li><a href="#" target="_self" >Main Item 2</a>
<ul>
<li><a href="#" target="_self" >Test Sub Item</a></li>
<li><a href="#" target="_self" >SUB SUB LIST 1 >></a>
<ul>
<li><a href="#" target="_self" >Sub Sub Test Item 1</a>
<li><a href="#" target="_self" >Sub Sub Test Item 2</a>
</ul>
</li>
<li><a href="#" target="_self" >SUB SUB LIST 2 >></a>
<ul>
<li><a href="#" target="_self" >Sub Sub Test Item 3</a>
<li><a href="#" target="_self" >Sub Sub Test Item 4</a>
</ul>
</li>
</ul>
</li>
<li><a href="#" target="_self" >Main Item 3</a></li>
</ul>
</div>
Related
We were following this tutorial (http://www.script-tutorials.com/click-action-multilevel-css3-dropdown-menu/). The goal was to create a multilevel dropdown click menu with css/html and no js. The code works fine in firefox and even works in the demo shown in the tutorial in chrome, but downloading the code and using it separately doesn't work in chrome. Anyone have any ideas why? The code for the menu is:
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
<div class="example">
<ul id="nav">
<li>Home</li>
<li><a class="fly" href="#">Tutorials</a>
<ul class="dd">
<li>HTML / CSS</li>
<li><a class="fly" href="#">JS / jQuery</a>
<ul>
<li>jQuery</li>
<li>JS</li>
</ul>
</li>
<li>PHP</li>
<li>MySQL</li>
<li>XSLT</li>
<li>Ajax</li>
</ul>
</li>
<li><a class="fly" href="#">Resources</a>
<ul class="dd">
<li><a class="fly" href="#">By category</a>
<ul>
<li>PHP</li>
<li>MySQL</li>
<li><a class="fly" href="#">Menu1</a>
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li><a class="fly" href="#">Menu3</a>
<ul>
<li>Menu31</li>
<li>Menu32</li>
<li>Menu33</li>
<li>Menu34</li>
</ul>
</li>
<li>Menu4</li>
</ul>
</li>
<li>Ajax</li>
</ul>
</li>
<li><a class="fly" href="#">By tag name</a>
<ul>
<li>captcha</li>
<li>gallery</li>
<li>animation</li>
</ul>
</li>
</ul>
</li>
<li>About</li>
<li>Go Back To The Tutorial</li>
</ul>
</div>
/* demo page styles */
body {
background:#eee;
margin:0;
padding:0;
}
.example {
background:#fff url(../images/tech.jpg);
width:770px;
height:570px;
border:1px #000 solid;
margin:20px auto;
padding:15px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
/* main menu styles */
#nav,#nav ul {
background-image:url(../images/tr75.png);
list-style:none;
margin:0;
padding:0;
}
#nav {
height:41px;
padding-left:5px;
padding-top:5px;
position:relative;
z-index:2;
}
#nav ul {
left:-9999px;
position:absolute;
top:37px;
width:auto;
}
#nav ul ul {
left:-9999px;
position:absolute;
top:0;
width:auto;
}
#nav li {
float:left;
margin-right:5px;
position:relative;
}
#nav li a {
background:#c1c1bf;
color:#000;
display:block;
float:left;
font-size:16px;
padding:8px 10px;
text-decoration:none;
}
#nav > li > a {
-moz-border-radius:6px;
-webkit-border-radius:6px;
-o-border-radius:6px;
border-radius:6px;
overflow:hidden;
}
#nav li a.fly {
background:#c1c1bf url(../images/arrow.gif) no-repeat right center;
padding-right:15px;
}
#nav ul li {
margin:0;
}
#nav ul li a {
width:120px;
}
#nav ul li a.fly {
padding-right:10px;
}
/*hover styles*/
#nav li:hover > a {
background-color:#858180;
color:#fff;
}
/*focus styles*/
#nav li a:focus {
outline-width:0;
}
/*popups*/
#nav li a:active + ul.dd,#nav li a:focus + ul.dd,#nav li ul.dd:hover {
left:0;
}
#nav ul.dd li a:active + ul,#nav ul.dd li a:focus + ul,#nav ul.dd li ul:hover {
left:140px;
}
New css Worked for me in both crome and firefox!::::
body {
background:#eee;
margin:0;
padding:0;
}
.example {
background:#fff url(../images/tech.jpg);
width:770px;
height:570px;
border:1px #000 solid;
margin:20px auto;
padding:15px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
/* main menu styles */
#nav,#nav ul {
background-image:url(../images/tr75.png);
list-style:none;
margin:0;
padding:0;
}
#nav {
height:41px;
padding-left:5px;
padding-top:5px;
position:relative;
z-index:2;
}
#nav ul {
left:-9999px;
position:absolute;
top:37px;
width:auto;
}
#nav ul ul {
left:-9999px;
position:absolute;
top:0;
width:auto;
}
#nav li {
float:left;
margin-right:5px;
position:relative;
}
#nav li a {
background:#c1c1bf;
color:#000;
display:block;
float:left;
font-size:16px;
padding:8px 10px;
text-decoration:none;
}
#nav > li > a {
-moz-border-radius:6px;
-webkit-border-radius:6px;
-o-border-radius:6px;
border-radius:6px;
overflow:hidden;
}
#nav li a.fly {
background:#c1c1bf url(../images/arrow.gif) no-repeat right center;
padding-right:15px;
}
#nav ul li {
margin:0;
}
#nav ul li a {
width:120px;
}
#nav ul li a.fly {
padding-right:10px;
}
/*hover styles*/
#nav li:hover > a {
background-color:#858180;
color:#fff;
}
/*focus styles*/
#nav li a:focus {
outline-width:0;
}
/*popups*/
#nav li a:hover + ul.dd,#nav li a:focus + ul.dd,#nav li ul.dd:hover {
left:0;
}
#nav ul.dd li a:hover + ul,#nav ul.dd li a:focus + ul,#nav ul.dd li ul:hover {
left:140px;
}
In files for download is different html page. Difference is that live demo contain attribute tabindex="1" in some links. I downloaded source code from live example and it works in chrome now.
New code for your html page.
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
<div class="example">
<ul id="nav">
<li>Home</li>
<li><a class="fly" href="#" tabindex="1">Tutorials</a>
<ul class="dd">
<li>HTML / CSS</li>
<li><a class="fly" href="#" tabindex="1">JS / jQuery</a>
<ul>
<li>jQuery</li>
<li>JS</li>
</ul>
</li>
<li>PHP</li>
<li>MySQL</li>
<li>XSLT</li>
<li>Ajax</li>
</ul>
</li>
<li><a class="fly" href="#" tabindex="1">Resources</a>
<ul class="dd">
<li><a class="fly" href="#" tabindex="1">By category</a>
<ul>
<li>PHP</li>
<li>MySQL</li>
<li><a class="fly" href="#" tabindex="1">Menu1</a>
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li><a class="fly" href="#" tabindex="1">Menu3</a>
<ul>
<li>Menu31</li>
<li>Menu32</li>
<li>Menu33</li>
<li>Menu34</li>
</ul>
</li>
<li>Menu4</li>
</ul>
</li>
<li>Ajax</li>
</ul>
</li>
<li><a class="fly" href="#" tabindex="1">By tag name</a>
<ul>
<li>captcha</li>
<li>gallery</li>
<li>animation</li>
</ul>
</li>
</ul>
</li>
<li>About</li>
<li>Go Back To The Tutorial</li>
</ul>
</div>
Here's the code. Notice that's NOT my code.
HTML:
<div class="drop">
<ul class="drop_menu">
<li><a href='#'>Link 1</a>
<ul>
<li><a href='#'>Sub Link 1</a></li>
<li><a href='#'>Sub Link 2</a></li>
</ul>
</li>
<li><a href='#'>Link 2</a>
<ul>
<li><a href='#'>Sub Link 1</a></li>
<li><a href='#'>Sub Link 2</a></li>
<li><a href='#'>Sub Link 3</a></li>
<li><a href='#'>Sub Link 4</a></li>
</ul>
</li>
<li><a href='#'>Link 3</a>
<ul>
<li><a href='#'>Sub Link 1</a></li>
<li><a href='#'>Sub Link 2</a></li>
<li><a href='#'>Sub Link 3</a></li>
<li><a href='#'>Sub Link 4</a></li>
</ul>
</li>
</ul>
</div>
CSS:
.drop_menu {
background:#005555;
padding:0;
margin:0;
list-style-type:none;
height:30px;
}
.drop_menu li { float:left; }
.drop_menu li a {
padding:9px 20px;
margin-left:auto;
margin-right:auto;
display:block;
color:#fff;
text-decoration:none;
font:12px arial, verdana, sans-serif;
}
/* Submenu */
.drop_menu ul {
position:absolute;
left:-9999px;
top:-9999px;
list-style-type:none;
}
.drop_menu li:hover { position:relative; background:#5FD367; }
.drop_menu li:hover ul {
left:0px;
top:30px;
background:#5FD367;
padding:0px;
}
.drop_menu li:hover ul li a {
padding:5px;
display:block;
width:168px;
text-indent:15px;
background-color:#5FD367;
}
.drop_menu li:hover ul li a:hover { background:#005555; }
My question is, how can I center the "Link 1", "Link 2" and "Link 3"? On the future, I'll add more "Link 4,5,6...", so I need a solution that doesn't require "almost centered", but a permanent solution.
Can you please help me?
Here's a link to JSFiddle where you can see the code working - http://jsfiddle.net/W5F3p/
My best regards
If you're not supporting IE7 and below, I'd change the float:left on the li to a display:inline-block and then add text-align:center to the parent ul.
.drop_menu {
background:#005555;
padding:0;
margin:0;
list-style-type:none;
height:30px;
text-align:center;
}
.drop_menu li { display:inline-block; }
.drop_menu li a {
padding:9px 20px;
margin-left:auto;
margin-right:auto;
display:block;
color:#fff;
text-decoration:none;
font:12px arial, verdana, sans-serif;
}
/* Submenu */
.drop_menu ul {
position:absolute;
left:-9999px;
top:-9999px;
list-style-type:none;
}
.drop_menu li:hover { position:relative; background:#5FD367; }
.drop_menu li:hover ul {
left:0px;
top:30px;
background:#5FD367;
padding:0px;
}
.drop_menu li:hover ul li a {
padding:5px;
display:block;
width:168px;
text-indent:15px;
background-color:#5FD367;
text-align:left;
}
.drop_menu li:hover ul li a:hover { background:#005555; }
See here: http://jsfiddle.net/s6Jcx/1/
Use text align in the container tag and set the list to display inline-block:
http://jsfiddle.net/W5F3p/1/
.drop
{
text-align: center;
background:#005555;
}
A little hacky but does the trick.
I'm experiencing 4 issues with my current code that I cannot fix (every time I fix something it creates a collateral issue):
http://jsfiddle.net/88zNs/1/
The logo text is slightly (1 or 2px) lower than the menu items
The blue and the red DIVs should both have a fixed height of 80px and be
vertically centered in the #header DIV which has a height of 120px.
But for some reason the blue and red DIVs have both a height of 120px and we can't
see the black #header DIV behind.
My menu items are aligned to the left side of the red DIV but I'd like them to be aligned
to the right side (can't use float right if I want to keep the same
link order (Link 1, Link 2, Link 3)
The sub-menu items (sub-link1, sub-link2, etc) are floating next to each other whereas I'd like them under each other like on a normal drop down menu
I know it's a lot of question... Many thanks for you help
EDIT: thanks to salsaturion everything's almost fixed http://jsfiddle.net/88zNs/9/ Remaining issue is that the items order are now in the wrong order due to float: right
HTML:
<div id="header">
<div class="logo">Logo</div>
<ul class="drop_menu">
<li><a href='#'>Link 1</a>
<ul>
<li><a href='#'>Sub Link 1</a>
</li>
<li><a href='#'>Sub Link 2</a>
</li>
</ul>
</li>
<li><a href='#'>Link 2</a>
<ul>
<li><a href='#'>Sub Link 1</a>
</li>
<li><a href='#'>Sub Link 2</a>
</li>
<li><a href='#'>Sub Link 3</a>
</li>
<li><a href='#'>Sub Link 4</a>
</li>
</ul>
</li>
<li><a href='#'>Link 3</a>
<ul>
<li><a href='#'>Sub Link 1</a>
</li>
<li><a href='#'>Sub Link 2</a>
</li>
<li><a href='#'>Sub Link 3</a>
</li>
<li><a href='#'>Sub Link 4</a>
</li>
</ul>
</li>
</ul>
</div>
CSS:
#header {
width: 100%;
height: 120px;
background: #fff;
color: #124191;
font-weight: 300;
font-size: 28px;
display: table;
background: #000;
position: fixed;
}
.logo {
background: aqua;
display: table-cell;
vertical-align: middle;
left:0;
height:80px;
}
/* ==========================================================================
Site Navigation
========================================================================== */
/* CSSTerm.com Simple Horizontal DropDown CSS menu */
.drop_menu {
background:red;
padding:0;
margin:0;
list-style-type:none;
height:80px;
right: 0;
display: table;
z-index: 3000;
display: table-cell;
vertical-align: middle;
right: 0;
}
.red {
background:red;
}
.green {
background:green;
height: 60px;
-webkit-transition-duration: 400ms;
-webkit-transition-function: linear;
}
.drop_menu li {
display: table-cell;
vertical-align: middle;
}
.drop_menu li a {
padding:9px 20px;
display:block;
color:#666;
text-decoration:none;
font-size: 15px;
font-weight: 400;
text-transform: uppercase;
}
/* Submenu */
.drop_menu ul {
position:absolute;
left:-9999px;
top:-9999px;
list-style-type:none;
}
.drop_menu li:hover {
position:relative;
background:#5FD367;
}
.drop_menu li:hover ul {
left:0px;
top:30px;
background:#5FD367;
padding:0px;
}
.drop_menu li:hover ul li a {
padding:5px;
display:block;
width:168px;
text-indent:15px;
background-color:#5FD367;
}
.drop_menu li:hover ul li a:hover {
background:#005555;
}
.block {
width:100%;
height: 500px;
}
Quickly looked at issue 2 and the reason is because of the table-cell. The following should have the same effect and leave the div as 80px in height:
.logo {
background: aqua;
vertical-align: middle;
line-height: 80px; /* this is set to same height as the div */
left:0;
height:80px;
margin: 20px 0;
}
Will have a look at the other questions when I get a chance
EDIT:
1) Don't see the issue - they all look like they are aligned
2) As per above
3 and 4) Adding float: right to .drop_menu li should fix both issues
I have a horizontal ccs dropdown menu which isn't working in IE. the colors doesn't hover and the dropdown won't come down. It works in the other browsers like Safari, firefox etc. I have IE 10.
What have i done wrong?
Here is my HTML:
<ul class="nav">
<li><a href = '#'><img src="images/house.png"/></a></li>
<li class="menu"><a href = '#'><span>Je Studie</span></a>
<ul>
<li><a href='#'>Programma</a></li>
<li><a href='#'>Begeleiding</a></li>
<li><a href='#'>Locaties</a></li>
<li><a href='#'>Open dag</a></li>
<li><a href='#'>Toelatingseisen</a></li>
<li><a href='#'>Aanmelden</a></li>
</ul>
</li>
<li class="menu"><a href = '#'><span>Voor ouders</span></a>
<ul>
<li><a href='#'>Studiekeuzeproces</a></li>
<li><a href='#'>Studiekeuzeactiviteiten</a></li>
<li><a href='#'>Het puberbrein</a></li>
<li><a href='#'>Tips</a></li>
<li><a href='#'>Begeleiding</a></li>
</ul>
</li>
<li class="menu"><a href = '#'><span>Voor decanen</span></a>
<ul>
<li><a href='#'>Advies</a></li>
<li><a href='#'>Studiekeuzeactiviteiten</a></li>
<li><a href='#'>Decanennieuws</a></li>
</ul>
</li>
<li class="menu"><a href = '#'><span>Voor bedrijven</span></a>
<ul>
<li><a href='#'>Opleiding</a></li>
<li><a href='#'>Opdrachtstages</a></li>
<li><a href='#'>Afstudeeropdrachten</a></li>
</ul>
</li>
<li class="menu"><a href = '#'><span>Contact</span></a></li>
</ul>
and my CSS:
.nav , .nav ul {
list-style-type:none;
background:#d70047;
}
.nav {
position:relative;
height:37;
background:#d70047;
}
.nav a {display:block;
color:white;
font-family:Myriad Pro;
font-size:16px;
}
.nav li{
float:left;
margin:3px 0px 0px 0px;
padding:3px 10px;
}
.nav .menu{
padding:11px 47px 7px 47px;
margin:0px 0px 0px 0px;
}
.nav .menu:hover{
background:#e3e1e1;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.nav ul{
visibility:hidden;
top:100%;
left:0;
position:absolute;
background:#e3e1e1;
width:920px;
height:33;
}
.nav ul li a{
font-family:Myriad Pro;
font-size:15px;
color:black !important;
}
.nav .menu:hover a{
color:#1882a5;}
.nav ul li{
background:#e3e1e1;
padding:5px 50px 5px 5px;
}
.nav ul li:hover{
}
.nav ul li:hover a{
text-decoration:underline;
font:bold;
}
.nav li:hover>ul{
visibility:visible;
}
Have you tried changing your heights to px values, i.e. height: 37px; and height: 33px;? If that's it, it's possible that the other browsers are assuming that you meant px where IE might not.
Have you tried em instead of px.
I want do a menu like on this site: http://www.accenture.com/us-en/pages/index.aspx ex. outsourcing. It's possible to do this using css and html. I can't create "li" or "ul" with columns.
My code
<body>
<style type="text/css">#cssmenu{
border:none;
border:0px;
margin:0px;
padding:0px;
font-family:verdana,geneva,arial,helvetica,sans-serif;
font-size:12px;
font-weight:bold;
color:8e8e8e;
}
#cssmenu ul{
background:url(menu_assets/images/menu-bg.gif) top left repeat-x;
height:43px;
list-style:none;
margin:0;
padding:0;
}
#cssmenu li{
float:left;
padding:0px 8px 0px 8px;
}
#cssmenu li a{
color:#666666;
display:block;
font-weight:bold;
line-height:43px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
#cssmenu li a:hover{
color:#000000;
text-decoration:underline;
}
#cssmenu li ul{
background:#e0e0e0;
border-left:1px solid #0079b2;
border-right:1px solid #0079b2;
border-bottom:1px solid #0079b2;
display:none;
height:auto;
filter:alpha(opacity=95);
opacity:0.95;
position:absolute;
width:600px;
/*top:1em;
/*left:0;*/
}
#cssmenu li:hover ul{
display:block;
}
#cssmenu li li {
display:block;
float:none;
padding:0px;
width:225px;
}
#cssmenu li ul a{
display:block;
font-size:12px;
font-style:normal;
padding:0px 10px 0px 15px;
text-align:left;
}
#cssmenu li ul a:hover{
background:#949494;
color:#000000;
opacity:1.0;
filter:alpha(opacity=100);
}
#cssmenu p{
clear:left;
}
#cssmenu .active > a{
background:url(menu_assets/images/current-bg.gif) top left repeat-x;
color:#ffffff;
}
#cssmenu .active > a:hover {
color:#ffffff;
}
</style>
<div id='cssmenu'>
<ul>
<li class='active'><a href='index.html'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Products</span></a>
<ul>
<li><a href='#'><span>Product 1</span></a></li>
<li><a href='#'><span>Product 2</span></a></li>
<li><a href='#'><span>Product 3</span></a></li>
<li><a href='#'><span>Product 3</span></a></li>
<li class='last'><a href='#'><span>Product 4</span></a></li>
</ul>
</li>
<li><a href='#'><span>About</span></a></li>
<li class='last'><a href='#'><span>Contact</span></a></li>
</ul>
</div>
<div style="clear:both; margin: 0 0 30px 0;"> </div>
</body>
Of course I search on web but I can't find solution.
Specific selectors
First off, when you use a CSS rule like #cssmenu ul or #cssmenu li, that CSS rule will get applied to the HTML tags for both the main menu and the sub-menus. Some of the styles may be getting applied to elements where they don't need to be applied. To avoid this possible confusion, use the > child combinator in more of the CSS selectors. For example:
#cssmenu > ul {...} // Only applied to main menu
#cssmenu > ul > li {...} // Only applied to main menu li tags
#cssmenu > ul > li > a {...} // Only applied to main menu links
#cssmenu ul ul {...} // No confusion here, since menu isn't 3 levels deep
#cssmenu ul ul li {...} // No confusion here, only applied to submenu li tags
#cssmenu ul ul li a {...} // No confusion here, only applied to submenu links
Floating the menu items
Second, if you're imitating the Accenture menu, the quickest way to display variable-width menu items on the right side of the page is to float the menu items to the left while floating the menu as a whole to the right.
#cssmenu > ul { float: right; ... }
#cssmenu > ul > li { float: left; ... }
...
<ul>
<li class='active'><a href='index.html'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Products</span></a> ... </li>
<li><a href='#'><span>About</span></a></li>
<li class='last'><a href='#'><span>Contact</span></a></li>
</ul>
Sometimes floating a parent and child in opposite directions is problematic. If you have any trouble doing so, the safest option is to float the menu items to the right. In that case, to get them to display in the correct order, you'll have to reverse the order of the menu items in the HTML source code.
#cssmenu > ul > li { float: right; ... }
...
<ul>
<li class='last'><a href='#'><span>Contact</span></a></li>
<li><a href='#'><span>About</span></a></li>
<li class='has-sub'><a href='#'><span>Products</span></a> ... </li>
<li class='active'><a href='index.html'><span>Home</span></a></li>
</ul>