SuzanneB
05-26-2008, 11:50 AM
I have a question!
Centauri poseted some code for me to try, for dropdown menus.
<div id="menu">
<h5>Help<br>Topics</h5>
<ul>
<li><a href="help_cancellations.php">Cancellations</a>
<ul>
<li><a href="#">topic 1</a></li>
<li><a href="#">topic 2</a></li>
<li><a href="#">topic 3</a></li>
</ul>
</li>
<li><a href="help_contact_us.php">Contact Us</a>
<ul>
<li><a href="#">Manager</a></li>
<li><a href="#">Secretary</a></li>
<li><a href="#">Foreman</a></li>
<li><a href="#">Accountant</a></li>
<li><a href="#">Technician</a></li>
<li><a href="#">Labourer</a></li>
<li><a href="#">Floor Sweeper</a></li>
</ul>
</li>
<li><a href="help_dispatch_times.php">Dispatch Times</a>
<ul>
<li><a href="#">Week days</a></li>
<li><a href="#">Weekends</a></li>
</ul>
</li>
</ul>
</div>
And
<div id="menu">
<h5>Help<br>Topics</h5>
<ul>
<li><a href="help_cancellations.php">Cancellations</a>
<ul>
<li><a href="#">topic 1</a></li>
<li><a href="#">topic 2</a></li>
<li><a href="#">topic 3</a></li>
</ul>
</li>
<li><a href="help_contact_us.php">Contact Us</a>
<ul>
<li><a href="#">Manager</a></li>
<li><a href="#">Secretary</a></li>
<li><a href="#">Foreman</a></li>
<li><a href="#">Accountant</a></li>
<li><a href="#">Technician</a></li>
<li><a href="#">Labourer</a></li>
<li><a href="#">Floor Sweeper</a></li>
</ul>
</li>
<li><a href="help_dispatch_times.php">Dispatch Times</a>
<ul>
<li><a href="#">Week days</a></li>
<li><a href="#">Weekends</a></li>
</ul>
</li>
</ul>
</div>The additional nested lists I have highlighted in blue.
As the nested lists are contained within the main <li>s, the hover function to show them must operate on the <li>s and not the <a> elements. Basically, the process is to position the submenu <ul>s absolutely but referenced to the parent <li>s (so therefore the <li>s get a relative position), and have them initially positioned way off to the left of the screen until the <li>s are hovered, wherupon the submenu is positioned back into view. The css to operate the above could be :
Code:
#menu {
font-size: 10pt;
font-weight:bold;
border:1px solid #666666;
background-color:#363636;
color:#CCCCCC;
padding:4px 0 0 0;
margin: 0 0 4px 0;
width: 144px;
}
#menu h5 {
margin:0 0 12px 5px;
font-size:1em;
}
#menu ul {
margin: 0;
padding:0;
list-style-type:none;
}
#menu li {
position: relative;
}
* html #menu li {
float: left;
}
#menu a {
display: block;
padding: 1px 0px 1px 5px;
width:139px;
text-decoration: none;
background-color:#D0D0D0;
color:#504040;
}
#menu li:hover li a, #menu li.sfhover li a {
background-color: #D0D0D0;
color: #504040;
}
#menu li:hover a, #menu li.sfhover a,
#menu li li:hover a, #menu li li.sfhover a {
background-color: #990000;
color: #FFFFFF;
}
#menu ul ul {
position: absolute;
top: -1px;
left: -999em;
border: 1px solid #666666;
}
#menu li:hover ul, #menu li.sfhover ul {
left: 139px;
z-index: 100;
}
And
<script type="text/javascript" src="sfhover.js"></script>
This is great, and works a treat, except for one unforseen thing.
I need to mimic the original code that I am modifying, and it calls for some of the menu items to be a different foreground and background color. What currently generates the color for them all is the statement in the above code
#menu a {
display: block;
padding: 1px 0px 1px 5px;
width:139px;
text-decoration: none;
background-color:#D0D0D0;
color:#504040;
But any attempt by me to remove the color statements from the code, so they can be generated someplace else, and so varied for different menu items, results in some very strange bugs in IE7.
Trying the code
#menu a {
display: block;
padding: 1px 0px 1px 5px;
width:139px;
text-decoration: none;}
Then using some other statement to specify color, for example,
.color1 {background-color:#D0D0D0; color:#504040;}
.color2 {background-color:#AAAAAA; color:#504040;}
causes problems.
Any ideas...??
Centauri poseted some code for me to try, for dropdown menus.
<div id="menu">
<h5>Help<br>Topics</h5>
<ul>
<li><a href="help_cancellations.php">Cancellations</a>
<ul>
<li><a href="#">topic 1</a></li>
<li><a href="#">topic 2</a></li>
<li><a href="#">topic 3</a></li>
</ul>
</li>
<li><a href="help_contact_us.php">Contact Us</a>
<ul>
<li><a href="#">Manager</a></li>
<li><a href="#">Secretary</a></li>
<li><a href="#">Foreman</a></li>
<li><a href="#">Accountant</a></li>
<li><a href="#">Technician</a></li>
<li><a href="#">Labourer</a></li>
<li><a href="#">Floor Sweeper</a></li>
</ul>
</li>
<li><a href="help_dispatch_times.php">Dispatch Times</a>
<ul>
<li><a href="#">Week days</a></li>
<li><a href="#">Weekends</a></li>
</ul>
</li>
</ul>
</div>
And
<div id="menu">
<h5>Help<br>Topics</h5>
<ul>
<li><a href="help_cancellations.php">Cancellations</a>
<ul>
<li><a href="#">topic 1</a></li>
<li><a href="#">topic 2</a></li>
<li><a href="#">topic 3</a></li>
</ul>
</li>
<li><a href="help_contact_us.php">Contact Us</a>
<ul>
<li><a href="#">Manager</a></li>
<li><a href="#">Secretary</a></li>
<li><a href="#">Foreman</a></li>
<li><a href="#">Accountant</a></li>
<li><a href="#">Technician</a></li>
<li><a href="#">Labourer</a></li>
<li><a href="#">Floor Sweeper</a></li>
</ul>
</li>
<li><a href="help_dispatch_times.php">Dispatch Times</a>
<ul>
<li><a href="#">Week days</a></li>
<li><a href="#">Weekends</a></li>
</ul>
</li>
</ul>
</div>The additional nested lists I have highlighted in blue.
As the nested lists are contained within the main <li>s, the hover function to show them must operate on the <li>s and not the <a> elements. Basically, the process is to position the submenu <ul>s absolutely but referenced to the parent <li>s (so therefore the <li>s get a relative position), and have them initially positioned way off to the left of the screen until the <li>s are hovered, wherupon the submenu is positioned back into view. The css to operate the above could be :
Code:
#menu {
font-size: 10pt;
font-weight:bold;
border:1px solid #666666;
background-color:#363636;
color:#CCCCCC;
padding:4px 0 0 0;
margin: 0 0 4px 0;
width: 144px;
}
#menu h5 {
margin:0 0 12px 5px;
font-size:1em;
}
#menu ul {
margin: 0;
padding:0;
list-style-type:none;
}
#menu li {
position: relative;
}
* html #menu li {
float: left;
}
#menu a {
display: block;
padding: 1px 0px 1px 5px;
width:139px;
text-decoration: none;
background-color:#D0D0D0;
color:#504040;
}
#menu li:hover li a, #menu li.sfhover li a {
background-color: #D0D0D0;
color: #504040;
}
#menu li:hover a, #menu li.sfhover a,
#menu li li:hover a, #menu li li.sfhover a {
background-color: #990000;
color: #FFFFFF;
}
#menu ul ul {
position: absolute;
top: -1px;
left: -999em;
border: 1px solid #666666;
}
#menu li:hover ul, #menu li.sfhover ul {
left: 139px;
z-index: 100;
}
And
<script type="text/javascript" src="sfhover.js"></script>
This is great, and works a treat, except for one unforseen thing.
I need to mimic the original code that I am modifying, and it calls for some of the menu items to be a different foreground and background color. What currently generates the color for them all is the statement in the above code
#menu a {
display: block;
padding: 1px 0px 1px 5px;
width:139px;
text-decoration: none;
background-color:#D0D0D0;
color:#504040;
But any attempt by me to remove the color statements from the code, so they can be generated someplace else, and so varied for different menu items, results in some very strange bugs in IE7.
Trying the code
#menu a {
display: block;
padding: 1px 0px 1px 5px;
width:139px;
text-decoration: none;}
Then using some other statement to specify color, for example,
.color1 {background-color:#D0D0D0; color:#504040;}
.color2 {background-color:#AAAAAA; color:#504040;}
causes problems.
Any ideas...??