How to set width and text-align for button with CSS - html

There are my problems:
The width's buttons are not the same as (1 & 2) in my image below.
Shorten the distance between Yearly, Monthly and Weekly as (3)
Please tell me how to correct this.
Demo
HTML:
<!-- Make a menu with Yearly, Monthly and Weekly -->
<ul id="out_per_chart">
<li>
<div class="yearly">
<div class="title">2014</div>
<div class="container1">
<ul class="sub-menu1">
<li class="year"><a class="_link" href="/Lists/ChartIndex.aspx?week=1&month=1&year=2014">Yearly</a>
</li>
<li>
<div class="monthly">
<div class="title">Monthly</div>
<div class="container2">
<ul class="sub-menu2"></ul>
</div>
</div>
</li>
<li>
<div class="weekly">
<div class="title">Weekly</div>
<div class="container3">
<ul class="sub-menu3"></ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</li>
</ul>
CSS:
#out_per_chart li {
list-style-type: none;
}
#out_per_chart .title {
border: 2px solid #2676ac;
padding: 10px 30px;
width: 40px;
color: #2676ac !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-bottom: 10px;
/* added */
}
#out_per_chart .title:hover {
border: 2px solid #259add;
cursor: default !important;
background: #259add;
color: #FFF !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-decoration: none !important;
}
.container1 {
position: absolute;
padding-left: -10px;
padding-top: -5px;
display: none;
}
.container2 {
position: absolute;
margin-top: -15px;
margin-left: 50px;
}
.container3 {
position: absolute;
margin-top: -15px;
margin-left: 50px;
}
._link {
text-decoration: none;
border: 2px solid #2676ac;
padding: 7px 20px 7px 20px;
width: 30px;
color: #2676ac !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
._link:hover {
text-decoration: underline;
cursor: pointer;
border: 2px solid #259add;
background: #259add;
color: #FFF !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#out_per_chart li {
width: 300px;
height: 30px;
margin-bottom: 25px;
}
#out_per_chart li.week_num, #out_per_chart li.month_num {
margin-left: 60px;
margin-top: -25px;
margin-bottom: 25px;
}
#out_per_chart li.year {
margin: 0 0 5px 0;
}

Your HTML markup is inconsistent, which won't make things easier. The menu for the first list item goes:
<li> > <a> then the child list elements have:
<li> > <div> > <div> > <ul>
The simplest way to achieve a consistent nested list/menu is something like this:
<ul id="main-list">
<li>Top level list item 1</a>
<ul>
<li>Second level list
<ul>
<li>Third level list item</li>
</ul>
</li>
</ul>
</li>
<li>Top level list item 2</a>
<li>Top level list item 3</a>
</ul>
Each menu is a child of the parent list item. Here's a Fiddle example of it in action.
It also addresses the width problem you're having.
By setting the <a> tags in the Fiddle example as block level, you can manipulate the width. By default, <a> tags are an inline element, and do not respond to width and height properties unless display:block is assigned.
If you absolutely must have an anchor link in some list items and not in others, then you'd need to set the widths on the parent element, in this case, the <li>

Structure Your HTML
http://jsfiddle.net/ug8rU/
Add your JS
http://jsfiddle.net/AywLf/
Add your CSS
http://jsfiddle.net/9v7tC/
here is the full code:
HTML
<ul class="record">
<li class="main-year">
2014
<ul class="main-menu">
<li class="cat-menu yearly">
Yearly
</li>
<li class="cat-menu monthly">
Monthly
<ul class="menu month-menu">
<li class="">Month 1</li>
<li class="">Month 2</li>
<li class="">Month 3</li>
</ul>
</li>
<li class="cat-menu weekly">
Weekly
<ul class="menu week-menu">
<li class="">Week 1</li>
<li class="">Week 2</li>
<li class="">Week 3</li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
.record{
width:300px;
}
.main-year{
width:300px;
}
.menu{
position:relative;
left:60px;
top:0px;
}
.menu{
top:-25px;
z-index:100;
}
.record li{
list-style:none;
height:25px;
margin:1px 3px;
}
.record a{
text-decoration:none;
border:2px solid #2676ac;
color: #2676ac !important;
width:90px;
padding:2px;
display:block;
text-align:center;
border-radius:5px;
}
JS
$(document).ready(function () {
$('.main-menu').hide();
$('.menu').hide();
$(".main-year").hover(function () {
$(this).children('.main-menu').show();
},
function () {
$(this).children('.main-menu').hide();
});
$(".monthly").hover(function () {
$(this).children('.month-menu').show();
},
function () {
$(this).children('.month-menu').hide();
});
$(".weekly").hover(function () {
$(this).children('.week-menu').show();
},
function () {
$(this).children('.week-menu').hide();
});
});

// ok test you this css code
#out_per_chart li {
list-style-type: none;
}
#out_per_chart .title {
border: 2px solid #2676AC;
border-radius: 5px;
color: #2676AC !important;
height: 40px;
line-height: 40px;
text-align: center;
width: 100px;
}
#out_per_chart .title:hover,
#out_per_chart li a:hover {
border: 2px solid #259add;
cursor: default !important;
background: #259add;
color: #FFF !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-decoration: none !important;
}
.sub-menu1{
padding:0;
margin:0;
}
.sub-menu1 li > a{
border: 2px solid #2676AC;
border-radius: 5px;
color: #2676AC !important;
height: 40px;
line-height: 40px;
text-align: center;
width: 100px;
display:block;
}
.container1 {
position: absolute;
padding-left: -10px;
padding-top: -5px;
display: none;
top:60px;
}
.container2 {
left: 45px;
position: absolute;
top: 43px;
}
.container3 {
position: absolute;
}
._link {
text-decoration: none;
border: 2px solid #2676ac;
color: #2676ac !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
._link:hover {
text-decoration: underline;
cursor: pointer;
border: 2px solid #259add;
background: #259add;
color: #FFF !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#out_per_chart li.week_num, #out_per_chart li.month_num {
margin-left: 60px;
}

Give a class for each box and have .class{width:"70px";margin-top:"3px";} in your css.
you can give a percent instead of giving it in px

.title
{
width: 80px;
text-align: center;
}
and the problem solved. If text doesn't align center between top and bottom you can
padding-top: 10px;
padding-bottom: 10px;
now you can see your text in center.
Sorry for bad english.

Related

Position of dropdown menu

I can't figure out how to position a dropdown menu below the list item that activates it. Right now each dropdown menu is placed independently.
ul{
display:inline-block;
list-style:none;
text-align:center;
width: 100%;
margin:0 auto;
}
ul li
{
display:inline;
padding:10px;
background-color:black;
color:white;
}
#listaUgn
{
display:block;
position:absolute;
}
#listaUgn li
{
display:block;
padding:10px;
background-color:black;
color:white;
max-width: 100px;
}
<div class="izborSrednji">
<ul id="listaSrednja">
<li class="izborLinije">Programiranje I</li>
<li class="izborLinije">WRD</li>
<li class="izborLinije" >Klikni za jos
<ul id="listaUgn" >
<li class="izborLinijeUg">Programiranje I</li>
<li class="izborLinijeUg">WRD</li>
<li class="izborLinijeUg">PSR</li>
<li class="izborLinijeUg">SP</li>
</ul>
</li>
<li class="izborLinije">SP</li>
</ul>
</div>
If you add position: relative to the dropdown element's parent, then the dropdown will be positioned absolutely, relative to it's parent element.
For example:
ul{
display:inline-block;
list-style:none;
text-align:center;
width: 100%;
margin:0 auto;
}
ul li
{
display:inline;
padding:10px;
background-color:black;
color:white;
position: relative;
}
ul li:hover #listaUgn {
display: block;
}
#listaUgn
{
display:none;
position:absolute;
padding: 0;
left: 0;
}
#listaUgn li
{
display:block;
padding:10px;
background-color:black;
color:white;
max-width: 100px;
}
<div class="izborSrednji">
<ul id="listaSrednja">
<li class="izborLinije">Programiranje I</li>
<li class="izborLinije">WRD</li>
<li class="izborLinije" >Klikni za jos
<ul id="listaUgn" >
<li class="izborLinijeUg">Programiranje I</li>
<li class="izborLinijeUg">WRD</li>
<li class="izborLinijeUg">PSR</li>
<li class="izborLinijeUg">SP</li>
</ul>
</li>
<li class="izborLinije">SP</li>
</ul>
</div>
this site can be a good reference for you: https://css-tricks.com/targetting-menu-elements-submenus-navigation-bar/
Update:
nav {
display: block;
text-align: center;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
.nav a {
display: block;
background: #111;
color: #fff;
text-decoration: none;
padding: 0.8em 1.8em;
text-transform: uppercase;
font-size: 80%;
letter-spacing: 2px;
text-shadow: 0 -1px 0 #000;
position: relative;
}
.nav {
vertical-align: top;
display: inline-block;
box-shadow: 1px -1px -1px 1px #000, -1px 1px -1px 1px #fff, 0 0 6px 3px #fff;
border-radius: 6px;
}
.nav li {
position: relative;
}
.nav>li {
float: left;
border-bottom: 4px #aaa solid;
margin-right: 1px;
}
.nav>li>a {
margin-bottom: 1px;
box-shadow: inset 0 2em .33em -0.5em #555;
}
.nav>li:hover,
.nav>li:hover>a {
border-bottom-color: orange;
}
.nav li:hover>a {
color: orange;
}
.nav>li:first-child {
border-radius: 4px 0 0 4px;
}
.nav>li:first-child>a {
border-radius: 4px 0 0 0;
}
.nav>li:last-child {
border-radius: 0 0 4px 0;
margin-right: 0;
}
.nav>li:last-child>a {
border-radius: 0 4px 0 0;
}
.nav li li a {
margin-top: 1px;
}
.nav li a:first-child:nth-last-child(2):before {
content: "";
position: absolute;
height: 0;
width: 0;
border: 5px solid transparent;
top: 50%;
right: 5px;
}
/* submenu positioning*/
.nav ul {
position: absolute;
white-space: nowrap;
border-bottom: 5px solid orange;
z-index: 1;
left: -99999em;
}
.nav>li:hover>ul {
left: auto;
margin-top: 5px;
min-width: 100%;
}
.nav>li li:hover>ul {
left: 100%;
margin-left: 1px;
top: -1px;
}
/* arrow hover styling */
.nav>li>a:first-child:nth-last-child(2):before {
border-top-color: #aaa;
}
.nav>li:hover>a:first-child:nth-last-child(2):before {
border: 5px solid transparent;
border-bottom-color: orange;
margin-top: -5px
}
.nav li li>a:first-child:nth-last-child(2):before {
border-left-color: #aaa;
margin-top: -5px
}
.nav li li:hover>a:first-child:nth-last-child(2):before {
border: 5px solid transparent;
border-right-color: orange;
right: 10px;
}
<html>
<head>
<title>test</title>
</head>
<body>
<nav>
<ul class="nav">
<li>About</li>
<li>Portfolio
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>Resume
<ul>
<li>item a lonng submenu</li>
<li>item
<ul>
<li>Ray</li>
<li>Veronica</li>
<li>Bushy</li>
<li>Havoc</li>
</ul>
</li>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>Download</li>
<li>Rants
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>Contact</li>
</ul>
</nav>
</body>
</html>

Increase width of menu on hover while preserving the position of other links

I am currently working on a horizontal menu using lists. My problem is that on hover I want to increase the width of the link while preserving the positioning of other links next to it(something like the image below).
Instead the link on hover increases the width and pushes the other links into the next line which I don't want it to do. Can some one help me figure out how I can do this. Thanks
https://jsfiddle.net/diviseed/k1wk9cvb/5/
#other-menu {
width: 850px;
background-color: #eee;
}
#other-menu li {
list-style: none;
float: left;
padding: 10px;
}
li a {
display: block;
color: #828282;
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
}
li {
display: block;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
}
li:hover {
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
background: #fff;
color: #828282 !important;
font-size: 12px;
letter-spacing: 2px;
line-height: 25px;
text-transform: uppercase;
border: 1px solid #eeeeee;
width: 15%;
height: 10px;
}
li a:hover {
text-decoration: none;
color: #828282 !important;
font-size: 12px;
}
<ul id="other-menu">
<li>Home
</li>
<li>
News
</li>
<li>
opinion
</li>
<li>
States
</li>
<li>
Cities
</li>
<li>
World
</li>
<li>
Opinion
</li>
<li>
Life & Style
</li>
<li>
Entertainment
</li>
<li>
EBusiness
</li>
<li>
ESport
</li>
</ul>
I would use a pseudo-element (:before) to style the hover event..
changes to CSS
li {
display: block;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
position:relative; /* set the parent to be relative */
}
li:hover:before { /* use the :before for styling */
content:'';
position:absolute; /* set styling box to be absolute position to not affect parent */
z-index:-1; /* set it behind the parent */
/*copy the properties the parent had*/
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
/* use positioning to grow its size in relation to parent */
top:-5px;
bottom:-5px;
left:-15px;
right:-15px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
background: #fff;
border: 1px solid #eeeeee;
}
Demo at https://jsfiddle.net/hvurs857/
#other-menu {width:850px; background-color:#eee;}
#other-menu li{ list-style:none; float:left; padding:10px;}
li a{
display: block;
color: #828282;
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
}
li {
display: block;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
position:relative;
}
li:hover:before {
content:'';
position:absolute;
z-index:-1;
display: block;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
top:-5px;
bottom:-5px;
left:-15px;
right:-15px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
background: #fff;
color: #828282 !important;
font-size: 12px;
letter-spacing: 2px;
line-height: 25px;
text-transform: uppercase;
border: 1px solid #eeeeee;
}
li a:hover {
text-decoration: none;
color: #828282 !important;
font-size:12px;
}
<ul id="other-menu" >
<li>Home</li>
<li>
News
</li>
<li>
opinion
</li>
<li>
States
</li>
<li>
Cities
</li>
<li>
World
</li>
<li>
Opinion
</li>
<li>
Life & Style</li>
<li>
Entertainment</li>
<li>
EBusiness</li>
<li>
ESport
</li>
</ul>
Add transform property
li:hover{transform: scale(1.5);}
Try it :
Edit in JSFiddle
JavaScript
HTML
CSS
Result
#other-menu {width:850px; background-color:#eee;}
#other-menu li{ list-style:none; float:left; padding:10px;}
li a{
display: block;
color: #828282;
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
width : 100;
}
li {
display: block;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
float : left ;
width : 100;
}
li:hover {
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
background: #fff;
color: #828282 !important;
font-size: 12px;
letter-spacing: 2px;
line-height: 25px;
text-transform: uppercase;
border: 1px solid #eeeeee;
width: 100;
height: 10px;
}
li a:hover {
text-decoration: none; color: #828282 !important; font-size:12px;
}

Align Image on Left Side of Menu CSS

I am trying to create a menu that has the image on the left and a menu on the right. But can't get the menu to style correctly. Currently, the image is on the top and menu is underneath it. Any suggestions?
Thanks!
Code in my common menu:
<div class = "firstDiv">
<img class = "myImage" src="font.jpg">
<div class = "secondDiv">
<nav>
<ul>
<li>Home</li>
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
<li>Page 4</li>
<li>Page 5</li>
<li>Page 6</li>
</ul>
</nav>
</div>
</div>
CSS Sheet:
nav{
display: block;
width: 100%;
overflow: hidden;
text-align: center;
}
nav ul {
padding: .7em;
list-style: none;
background: #2f2b23;
box-shadow: 0 1px 0 rgba(255,255,255,.5), 0 2px 1px rgba(0,0,0,.3) inset;
border: 3px solid black;
/* added*/
display: inline-block;
}
nav li {
float:left;
}
nav a {
float:left;
padding: .8em .7em;
text-decoration: none;
color: black;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
font: bold 1.1em/1 'trebuchet MS', Arial, Helvetica;
letter-spacing: 1px;
text-transform: uppercase;
border-width: 1px;
border-style: solid;
border-color: #black #BF7530;
background: #BF4630;
}
nav a:hover, nav a:focus {
outline: 0;
color: #black;
text-shadow: 0 1px 0 rgba(0,0,0,.2);
background: #FFDB73;
}
nav a:active {
box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
}
nav li:first-child a {
border-left: 0;
border-radius: 4px 0 0 4px;
}
nav li:last-child a {
border-right: 0;
border-radius: 0 4px 4px 0;
}
.firstDiv{
margin: 0 auto;
background: #a4d25d;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
border: 5px solid black;
width:1140px;
height: 362px;
}
.myImage {float:left; border: 5px solid black; margin:5px;}
.secondDiv{
border-spacing: 15px;
border: 4px solid black;
background-color: #FF8700;
margin: 0 auto;
}
Assuming that there is enough room for your image and menu (you didn't specify the image size) you just need to float .secondDiv
Example
.secondDiv{
float: left;
}
I believe you want to achieve similar like this demo does but you are complicating your design by not using right css and html markup:
html:
<header class="clearfix">
<div class="firstDiv">
<img class="myImage" src="font.jpg">
</div>
<div class="secondDiv">
<nav>
<ul>
<li>Home
</li>
<li>Page 1
</li>
</ul>
</nav>
</div>
</header>
CSS:
.firstDiv {
border: 5px solid black;
width:100px;
height: 110px;
float:left;
}
header{
padding: 5px;
background: #999;
}
.secondDiv {
border-spacing: 15px;
border: 4px solid black;
background-color: #FF8700;
float:left;
}
.clearfix:before,
.clearfix:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.clearfix:after {
clear: both;
}
Feel free to add your color styles again.

Issue building hover menu in CSS

I am trying to build a pure CSS hover menu and I having two issues with my current code.
When the user hovers over an li tag with a sub-menu ul tag, it push the item up instead of hovering below.
The sub-menu ul tag is not taking the width of the parent li tag
Here is the source code:
You can also see a working copy of the code here: http://jsfiddle.net/Fbgug/
HTML:
<ul id="subnav">
<li class="subnavtab">
Plan Your Visit
<ul class="sub-menu">
<li>Fee and Hours</li>
<li>Directions</li>
<li>Field Trips</li>
<li>Birthday Parties</li>
<li>Rentals</li>
</ul>
</li>
<li class="subnavtab">
Tour the Museum
<ul class="sub-menu">
<li>Artville</li>
<li>ArtZone</li>
<li>Exhibitions</li>
</ul>
</li>
<li class="subnavtab">
Program & Events
<ul class="sub-menu">
<li>Weather or Not</li>
<li>Classes & Workshops</li>
</ul>
</li>
<li class="subnavtab">Membership</li>
<li class="subnavtab">Donate</li>
</ul>
CSS:
#subnav { margin-top: 20px; width: 740px; float: left; position: relative; }
.subnavtab { background-color: #A1CD3A; padding: 10px 10px 10px 10px; margin: 0 1px 0 1px; display: inline-block;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
-webkit-border-radius-topright: 15px; -moz-border-radius-topright: 15px; border-top-right-radius: 15px;
-webkit-border-radius-topleft: 15px; -moz-border-radius-topleft: 15px; border-top-left-radius: 15px;
border-radius: 15px 15px 0px 0px;
behavior: url(pie.htc);
}
.subnavtab:first-child { margin-right: 3px; margin-left: 0px; }
.subnavtab:last-child { margin-right: 0px; margin-left: 3px; }
.subnavtab a { color: #000; text-decoration: none; font-weight: bold; font-size: large; }
.subnavtab a:hover { color: #fff; text-decoration: none; font-weight: bold; font-size: large; }
#subnav ul.sub-menu
{
display: none;
position: relative;
left: -10px;
padding: 10px;
z-index: 90;
list-style-type: none;
margin-left: 5px;
}
#subnav ul.sub-menu li { text-align: left; }
#subnav li:hover ul.sub-menu { display: block; background-color: #A1CD3A;
-webkit-border-bottom-right-radius: 15px; -moz-border-radius-bottomright: 15px; border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px; -moz-border-radius-bottomleft: 15px; border-bottom-left-radius: 15px;
border-radius: 0px 0px 15px 15px;
behavior: url(pie.htc);
}
#subnav ul.sub-menu a { color: #000; text-decoration: none; font-weight: bold; font-size: small; }
#subnav ul.sub-menu a:hover { color: #fff; text-decoration: none; font-weight: bold; font-size: small; }
Since your li elements have display: inline-block adding vertical-align: top; should do the trick:
.subnavtab {
...
vertical-align: top;
}
http://jsfiddle.net/Fbgug/1/
Add vertical-align: top; to .subnavtab.
EDIT: dfsq beat me to it.

dropdown menu not working in IE8 css

I have a drop down ul menu that is working in every browser except IE8. I have tried messing with the Z-index but haven't had much luck. When the user hovers over the first element, there is it displays the 2nd list as a drop down but then once the user tries to navigate to it, it disappears. Is there something else that I may be missing? Please help.
Here is the generated HTML:
<div id="topNav" class="topNavMenu">
<ul>
<li>Home</li>
<li><a rel="submenu1">Account Information</a></li>
<li><a rel="submenu2">Financial</a></li>
<li><a rel="submenu3">Pricing</a></li>
<li><a rel="submenu4">Operations</a></li>
<li><a rel="submenu5">Support</a></li>
<li><a rel="submenu6">Document Management</a></li>
<li><a rel="submenu7">Administration</a></li>
</ul>
<ul id="submenu1" class="ddsubmenustyle">
<li>Bill To/Ship To Search</li>
<li>Customer Account Information</li>
</ul>
<ul id="submenu2" class="ddsubmenustyle">
<li>Statement Search</li>
</ul>
<ul id="submenu3" class="ddsubmenustyle">
<li>Price Notification Summary</li>
</ul>
<ul id="submenu4" class="ddsubmenustyle">
<li>Online Environmental Compliance</li>
</ul>
<ul id="submenu5" class="ddsubmenustyle">
<li>Manage Profile</li>
<li>Administrative Interfaces</li>
</ul>
<ul id="submenu6" class="ddsubmenustyle">
<li>HES</li>
<li>Marketing Services</li>
<li>Sunoco University Classes</li>
<li>Credit Card Program Information</li>
</ul>
<ul id="submenu7" class="ddsubmenustyle">
<li>Create a New User</li>
<li>User Administration</li>
<li>Create a New Role</li>
<li>Maintain Menu Items</li>
<li>Refresh Menu</li>
</ul>
</div>
and the CSS:
/* Top navigation menu
topNavMenu = the class used on the menu div.
ddsubmenustyle = dropdown div css.
-----------------------------------------------------------*/
.topNavMenu ul
{
margin: 0;
padding: 0;
font: bold 12px Verdana;
list-style-type: none;
background: #C3C9D9; /* #153371 */
overflow: hidden;
width: 100%;
background-image:url(../images/menu_bg.png);
height:35px;
float:left;
}
.topNavMenu li
{
display: inline;
margin: 0;
z-index: 100;
}
.topNavMenu li a
{
float: left;
display: block;
text-decoration: none;
margin: 0;
padding: 0px 10px; /*padding inside each tab*/
border-right: 1px solid white; /*right divider between tabs*/
color: black;
background: #6c94b0; /* #153371 */
background-image:url(../images/menu_bg.png);
height:35px;
line-height:35px;
font-family:Verdana, Arial, Helvetica, sans-serif;
/*font-size:10px;*/
}
.topNavMenu li a:visited
{
color: black;
}
.topNavMenu li a:hover
{
background:#4D77A7; /*background of tabs for hover state */
color:White;
text-decoration:bold;
}
.topNavMenu a.selected
{
background: #4D77A7; /*background of tab with "selected" class assigned to its LI */
color:White;
}
.ddsubmenustyle, .ddsubmenustyle div
{ /*topmost and sub DIVs, respectively*/
font: normal 12px Verdana;
margin: 0;
font-weight:bold;
padding: 0;
position: absolute;
left: 0;
top: 0;
list-style-type: none;
background: white;
border-bottom-width: 0;
visibility: hidden;
z-index: 300;
}
.ddsubmenustyle ul
{
margin: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
list-style-type: none;
border: 0px none;
z-index: 300;
}
.ddsubmenustyle li a
{
display: block;
width: 170px; /*width of menu (not including side paddings)*/
color: white;
background-color: #aec6f6;
text-decoration: none;
padding: 4px 5px;
border-bottom: 1px solid white;
background-color:#4D77A7;
line-height:24px;
z-index: 300;
}
.ddsubmenustyle li ul li a, .ddsubmenustyle li ul li:first-child a
{
display: block;
width: 170px; /*width of menu (not including side paddings)*/
color: white;
background-color: #aec6f6;
text-decoration: none;
padding: 4px 5px;
border-bottom: 1px solid white;
background-color:#4D77A7;
line-height:24px;
background-image:none;
-moz-border-bottom-radius: none;
-webkit-border-bottom-radius: none;
-khtml-border-bottom-radius: none;
border-bottom-radius: none;
}
.ddsubmenustyle li:first-child a
{
display: block;
width: 170px; /*width of menu (not including side paddings)*/
color: white;
background-image:url(../images/arrow_first-child.png);
background-repeat:no-repeat;
background-position:top left;
background-color: #4D77A7;
text-decoration: none;
padding: 16px 5px 4px 5px;
border-bottom: 1px solid white;
background-color:#4D77A7;
}
.ddsubmenustyle li ul li:last-child a
{
-moz-border-bottom-right-radius: 0px;
-webkit-border-bottom-right-radius: 0px;
-khtml-border-bottom-right-radius: 0px;
border-bottom-right-radius: 0px;
-moz-border-bottom-left-radius: 0px;
-webkit-border-bottom-left-radius: 0px;
-khtml-border-bottom-left-radius: 0px;
border-bottom-left-radius: 0px;
border-bottom: none;
}
.ddsubmenustyle li ul li a:hover
{
background-color:#4D77A7;
color: 40638A;
line-height:24px;
}
.ddsubmenustyle li:last-child a
{
-moz-border-bottom-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-khtml-border-bottom-right-radius: 5px;
border-bottom-right-radius: 5px;
-moz-border-bottom-left-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-khtml-border-bottom-left-radius: 5px;
border-bottom-left-radius: 5px;
}
* html .ddsubmenustyle li
{ /*IE6 CSS hack*/
display: inline-block;
width: 170px; /*width of menu (include side paddings of LI A*/
}
.ddsubmenustyle li a:hover
{
background-color:#38587C;
color: white;
line-height:24px;
}
/* Neutral CSS */
.downarrowpointer
{ /*CSS for "down" arrow image added to top menu items*/
padding-left: 4px;
border: 0;
}
.rightarrowpointer
{ /*CSS for "right" arrow image added to drop down menu items*/
position: absolute;
padding-top: 3px;
left: 100px;
border: 0;
}
.ddiframeshim
{
position: absolute;
z-index: 500;
background: transparent;
border-width: 0;
width: 0;
height: 0;
display: block;
}
I tried to view this in Chrome but couldn't get it to work properly. Why are the sub-menus separate ul's? Perhaps you could try a nested list, like this:
<nav>
<ul class="top-nav">
<li>
Item 1
<ul class="sub-nav">
<li>Item 1a</li>
<li>Item 1b</li>
<li>Item 1c</li>
</ul>
</li>
<li>
Item 2
<ul class="sub-nav">
<li>Item 2a</li>
<li>Item 2b</li>
<li>Item 2c</li>
</ul>
</li>
</ul>
</nav>
And here's some CSS to make it work:
* {
margin: 0;
padding: 0;
list-style: none;
color: inherit;
text-decoration: none;
}
body {
font-family: sans-serif;
}
nav {
margin: 0 auto;
}
.sub-nav {
display: none;
}
.sub-nav li {
background: #333;
color: #fff;
padding: 4px 2px;
border-bottom: 1px solid #e0e0e0;
}
.top-nav {
overflow: hidden;
}
.top-nav > li {
float: left;
width: 100px;
padding: 4px 0;
background: #e0e0e0;
}
.top-nav > li:hover ul {
display: block;
}
Just tested in Chrome and IE, and worked fine.