Forum Moderators: not2easy

Message Too Old, No Replies

Two small problems in css

         

Peng

7:42 pm on Jul 1, 2006 (gmt 0)

10+ Year Member



First check this menu test page (in firefox)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Menus Work</title>
<style type="text/css" media="screen">

#menu {
width: 12em; /* set width of menu */
background: #FD7D41;
}

#menu ul { /* remove bullets and list indents */
list-style: none;
margin: 0;
padding: 0;
background: #fff;
}

/* style, color and size links and headings to suit */
#menu a, #menu h2 {
font: bold 13px Verdana, Arial, Helvetica, sans-serif;
display: block;
border-width: 1px;
border-style: solid;
border-color: #FD7D41;
margin: 0;
padding: 2px 3px;
}

#menu a {
color: #fff;
background: #FD7D41;
text-decoration: none;
}

#menu a:hover {
color: #FD7D41;
background: #fff;
}

#menu li {
/* make the list elements a containing block for the nested lists */
position: relative;
}

#menu ul ul ul {
position: absolute;
top: 0;
left: 100%; /* to position them to the right of their containing block */
width: 100%; /* width is based on the containing block */
}

div#menu ul ul ul,
div#menu ul ul li:hover ul ul
{display: none;}

div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}

div#menu ul ul li:hover ul a {
font: 11px Verdana, Arial, Helvetica, sans-serif;
color: #FD7D41;
background: #fff;
border-width: 1px;
border-color: #FD7D41;
}

div#menu ul ul ul li a:hover {
color: #fff;
background: #FD7D41;
}

</style>

</head>
<body>
<div id="menu">
<ul>
<li>
<ul>
<li><a href="" title="Statistics">Stats</a>
<ul>
<li style="border-color: #FD7D41 #FD7D41 #fff"><a href="" title="">Current Display</a></li>
<li style="border-color: #fff #FD7D41 #fff"><a href="" title="">Previous Display</a></li>
<li style="border-color: #fff #FD7D41 #FD7D41"><a href="" title="">Next Display</a></li>
</ul>
</li>
</ul>
</li>
</ul>

<ul>
<li>
<ul>
<li><a href="" title="Biography">Models</a> </li>
</ul>
</li>
</ul>

<ul>
<li>
<ul>
<li><a href="" title="News">Roadshow</a> </li>
</ul>
</li>
</ul>

</div>
</body>
</html>

Now when i hover over "Stat" submenu is displayed.

1) I want there should be only outer border for submenu and there should be complete white background of submenu without separating orange color between submenu items.

2) When i hover over "Stat" and move mouse to submenu items; background color of "Stat" goes back to orange but i want to keep it white same as when mouse hovers it.

Thanks for your time and help :)

[edit reason] added code and removed personal URL per TOS[/edit]

[edited by: SuzyUK at 4:29 pm (utc) on July 11, 2006]

SuzyUK

4:52 pm on Jul 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Peng..

I recognise my own code, I think ;)

I'll just post the amended CSS and hope it explains itself

#menu {
width: 12em; /* set width of menu */
background: #FD7D41;
}

#menu ul { /* remove bullets and list indents */
list-style: none;
margin: 0;
padding: 0;
background: #fff;
}

/* style, color and size links and headings to suit */
#menu a, #menu h2 {
font: bold 13px Verdana, Arial, Helvetica, sans-serif;
display: block;
border-width: 1px;
border-style: solid;
border-color: #FD7D41;
margin: 0;
padding: 2px 3px;
}

#menu a {
color: #fff;
background: #FD7D41;
text-decoration: none;
}

#menu a:hover {
color: #FD7D41;
background: #fff;
}

#menu li {
position: relative;
float: left; /* add this for IE's whitespace bug */
width: 100%; /* add this for IE's whitespace bug */
}

#menu ul ul ul {
position: absolute;
top: 0;
left: 100%;
width: 100%;
}

div#menu ul ul ul,
div#menu ul ul li:hover ul ul
{display: none;}

div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}

/* add this rule to put border around whole sub list instead of individual list items */
div#menu ul ul li:hover ul {
border: 1px solid #fd7d41;
}

/* add this rule to put borders around all the anchors */
div#menu ul ul li:hover a {
border: 1px solid #FD7D41;
background: #fff; /* moving this to the more general rule makes all descendant <a>'s of a hovered li remain white */
color: #FD7D41;
}

/* I removed a bunch out of here to the less specific rule above */
div#menu ul ul li:hover ul a {
font: 11px Verdana, Arial, Helvetica, sans-serif;
border: 0; /* add this rule to remove the border from drop list anchors */
}

div#menu ul ul ul li a:hover {
color: #fff;
background: #FD7D41;
}

Is that what you're after?

Suzy