MissIndependent
September 10th, 2008, 01:35 PM
http://www.htmldog.com/articles/suckerfish/dropdowns/ (http://www.htmldog.com/articles/suckerfish/dropdowns/)
I've attempted the tutorial successfully but now I'm trying to tweak the code to my liking.
When the user hovers over the MAIN menu item, I want the submenu to list items horizontally. So far, I've been able to do that successfully but I've run into an aesthetic problem; the items submenu items list horizontally in relative to the position of the MAIN menu item.
<html>
<head>
<title>MENU</title>
<style type="text/css">
<!--
#nav, #nav ul
{
padding: 0;
margin: 0;
list-style: none;
}
#nav li
{
float: left;
width: 10em;
}
#nav li ul {
position: absolute;
width: 10em;
left: -999em;
}
#nav li:hover ul
{
left: auto;
width: 50em;
}
#nav li:hover ul, #nav li.sfhover ul
{
left: auto;
width: 50em;
}
-->
</style>
<script type="text/javascript">
<!--
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++)
{
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<ul id="nav">
<li><a href="#">Percoidei</a> <br />
<ul>
<a href="#">Climbing perches</a>
<a href="#">Labyrinthfishes</a>
<a href="#">Kissing gouramis</a>
<a href="#">Pike-heads</a>
<a href="#">Giant gouramis</a>
</ul>
</li>
<li><a href="#">Anabantoidei</a> <br />
<ul>
<a href="#">Climbing perches</a>
<a href="#">Labyrinthfishes</a>
<a href="#">Kissing gouramis</a>
<a href="#">Pike-heads</a>
<a href="#">Giant gouramis</a>
</ul>
</li>
</ul>
</body>
</html>
I've attempted the tutorial successfully but now I'm trying to tweak the code to my liking.
When the user hovers over the MAIN menu item, I want the submenu to list items horizontally. So far, I've been able to do that successfully but I've run into an aesthetic problem; the items submenu items list horizontally in relative to the position of the MAIN menu item.
<html>
<head>
<title>MENU</title>
<style type="text/css">
<!--
#nav, #nav ul
{
padding: 0;
margin: 0;
list-style: none;
}
#nav li
{
float: left;
width: 10em;
}
#nav li ul {
position: absolute;
width: 10em;
left: -999em;
}
#nav li:hover ul
{
left: auto;
width: 50em;
}
#nav li:hover ul, #nav li.sfhover ul
{
left: auto;
width: 50em;
}
-->
</style>
<script type="text/javascript">
<!--
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++)
{
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<ul id="nav">
<li><a href="#">Percoidei</a> <br />
<ul>
<a href="#">Climbing perches</a>
<a href="#">Labyrinthfishes</a>
<a href="#">Kissing gouramis</a>
<a href="#">Pike-heads</a>
<a href="#">Giant gouramis</a>
</ul>
</li>
<li><a href="#">Anabantoidei</a> <br />
<ul>
<a href="#">Climbing perches</a>
<a href="#">Labyrinthfishes</a>
<a href="#">Kissing gouramis</a>
<a href="#">Pike-heads</a>
<a href="#">Giant gouramis</a>
</ul>
</li>
</ul>
</body>
</html>