Odd Behaviour (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets and Accessibility



Message


BeTheBall -> Odd Behaviour (5/15/2006 14:59:07)

I am trying to add the"Son of Suckerfish" menu to a site I am working on. This menu takes an unordered list and converts it to a dropdown menu system. I observed something that I am having trouble understanding. If I remove the background color from the list it breaks it. This is what happens - the middle and right links expand as they should but as you move the pointer down the sub options the options disappear before you can move the pointer over all of them. This only happens if I remove the background color. I don't understand how a simple attribute like that could have that kind of effect. Here is the code for my test page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<html>
<head>
<title>Suckerfish Dropdowns - Perciformes!</title>
<style type="text/css">
#nav, #nav ul {
	float: left;
	width: 100%;
	list-style: none;
	line-height: 1;
	background-color: white;
	font-weight: bold;
	padding: 0;
	border: solid #eda;
	border-width: 1px 0;
	margin: 0 0 1em 0;
}
#nav a {
	display: block;
	width: 10em;
	w\idth: 6em;
	color: #7C6240;
	text-decoration: none;
	padding: 0.25em 2em;
}
#nav a.daddy {
	background: url(rightarrow2.gif) center right no-repeat;
}
#nav li {
	float: left;
	padding: 0;
	width: 10em;
}
#nav li ul {
	position: absolute;
	left: -999em;
	height: auto;
	width: 14.4em;
	w\idth: 13.9em;
	font-weight: normal;
	border-width: 0.25em;
	margin: 0;
}
#nav li li {
	padding-right: 1em;
	width: 13em
}
#nav li ul a {
	width: 13em;
	w\idth: 9em;
}
#nav li ul ul {
	margin: -1.75em 0 0 14em;
}
#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
	left: -999em;
}
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul {
	left: auto;
}
#nav li:hover, #nav li.sfhover {
	background: #eda;
}
</style>
<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls.onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls.onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>
</head>
<body>
<ul id="nav">
	<li><a href="#">Percoidei</a>
		<ul>
			<li><a href="#" class="daddy">Remoras</a>
				<ul>
					<li><a href="#" class="daddy">Echeneis</a>
						<ul>
							<li><a href="#">Sharksucker</a></li>
							<li><a href="#">Whitefin Sharksucker</a></li>
						</ul>
					</li>
					<li><a href="#" class="daddy">Phtheirichthys</a>
						<ul>
							<li><a href="#">Slender Suckerfish</a></li>
						</ul>
					</li>
					<li><a href="#" class="daddy">Remora</a>
						<ul>
							<li><a href="#">Whalesucker</a></li>
							<li><a href="#">Spearfish remora</a></li>
							<li><a href="#">Marlinsucker</a></li>
							<li><a href="#">Remora</a></li>
							<li><a href="#">Ceylonese remora</a></li>
						</ul>
					</li>
					<li><a href="#" class="daddy">Remorina</a>
						<ul>
							<li><a href="#">White suckerfish</a></li>
						</ul>
					</li>
					<li><a href="#" class="daddy">Rhombochirus</a>
						<ul>
							<li><a href="#">R. osteochir</a></li>
						</ul>
					</li>
				</ul>
			</li>
			<li><a href="#" class="daddy">Tilefishes</a>
				<ul>
					<li><a href="#">Caulolatilus</a></li>
					<li><a href="#">Lopholatilus</a></li>
					<li><a href="#">Malacanthus</a></li>
				</ul>
			</li>
			<li><a href="#" class="daddy">Bluefishes</a>
				<ul>
					<li><a href="#">Pomatomus</a></li>
					<li><a href="#">Scombrops</a></li>
					<li><a href="#">Sphyraenops</a></li>
				</ul>
			</li>
			<li><a href="#" class="daddy">Tigerfishes</a>
				<ul>
					<li><a href="#">Amniataba</a></li>
					<li><a href="#">Bidyanus</a></li>
					<li><a href="#">Hannia</a></li>
					<li><a href="#">Hephaestus</a></li>
					<li><a href="#">Lagusia</a></li>
					<li><a href="#">Leiopotherapon</a></li>
					<li><a href="#">Mesopristes</a></li>
					<li><a href="#">Pelates</a></li>
					<li><a href="#">Pelsartia</a></li>
					<li><a href="#">Pingalla</a></li>
					<li><a href="#">Rhyncopelates</a></li>
					<li><a href="#">Scortum</a></li>
					<li><a href="#">Syncomistes</a></li>
					<li><a href="#">Terapon</a></li>
				</ul>
			</li>

		</ul>
	</li>
	<li><a href="#">Anabantoidei</a>
		<ul>
			<li><a href="#" class="daddy">Climbing perches</a>
				<ul>
					<li><a href="#">Anabas</a></li>
					<li><a href="#">Ctenopoma</a></li>
				</ul>
			</li>
			<li><a href="#" class="daddy">Labyrinthfishes</a>
				<ul>
					<li><a href="#">Belontia</a></li>
					<li><a href="#">Betta</a></li>
					<li><a href="#">Colisa</a></li>
					<li><a href="#">Macropodus</a></li>
					<li><a href="#">Malpulutta</a></li>
					<li><a href="#">Parosphromenus</a></li>
					<li><a href="#">Sphaerichthys</a></li>
					<li><a href="#">Trichogaster</a></li>
					<li><a href="#">Trichopsis</a></li>
				</ul>
			</li>
			<li><a href="#">Kissing gouramis</a></li>
			<li><a href="#">Pike-heads</a></li>
			<li><a href="#">Giant gouramis</a></li>
		</ul>
	</li>
	<li><a href="#">Gobioidei</a>
		<ul>
			<li><a href="#">Burrowing gobies</a></li>
			<li><a href="#">Dartfishes</a></li>
			<li><a href="#">Eellike gobies</a></li>
			<li><a href="#">Gobies</a></li>
			<li><a href="#">Loach gobies</a></li>
			<li><a href="#">Odontobutidae</a></li>
			<li><a href="#">Sandfishes</a></li>
			<li><a href="#">Schindleriidae</a></li>
			<li><a href="#">Sleepers</a></li>
			<li><a href="#">Xenisthmidae</a></li>
		</ul>
	</li>
</ul>
</body>
</html>


View the page in IE and it should work fine. Then remove this line:

background-color: white;

Hover over the items in the center and right lists and you should see what I am talking about.





jaybee -> RE: Odd Behaviour (5/15/2006 17:16:01)

It's all fine in FF with or without the background but in IE I can't get it to work at all, none of the dropdowns are appearing and it doesn't change whether the background is there or not.

The original suckerfish you got yours from works fine for me in IE.




Tailslide -> RE: Odd Behaviour (5/15/2006 17:36:34)

Hi Duane

It's very odd - never noticed it before. Has to be an actual colour too - not just "inherit" or "transparent".

BTW - there's a slight difference in the Javascript of the version in your post - should be:

<script type="text/javascript"><!--//--><![CDATA[//><!--

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls.onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls.onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>


Doesn't make any difference as far as working/not working goes though!

Edit: sorry - can't get the correct Javascript to paste onto this post correctly - it misses out the vital bit (which is probably why it's not in your post either Duane - not your error!

This bit won't appear in the code box (with added slashes):

sfEls/[/i/]/.onmouseover=function() {
and same for mouseout




rubyaim -> RE: Odd Behaviour (5/15/2006 18:57:21)

I think this is IE 6 bugginess at work.

I had a similar problem and found this at A List Apart
http://www.alistapart.com/articles/horizdropdowns
quote:


Mystery IE6 Bug:
During the development of this article, I uncovered a strange bug that I believe is only apparent in IE6. A background must be declared on the li a, else when a sub-menu stretches further (vertically) than the main menu itself, the links start to disappear before you have time to click them. Strange! Try it to see for yourself.


I did get your code to work in IE by changing the JS and see what you mean. I think you will have to leave the background in there somewhere, seems to look best when in the #nav.

Suckerfish menus have been slowly driving me crazy [sm=BangHead.gif]




jaybee -> RE: Odd Behaviour (5/15/2006 19:03:58)

Ah ha! so the js is missing a bit. Not a wonder it wouldn't work.




jaybee -> RE: Odd Behaviour (5/15/2006 19:05:31)

quote:

Suckerfish menus have been slowly driving me crazy


All I'm trying to do is format an ordinary list as a menu and IE is throwing a wobbler with that too! Sticking it in a separate post so's not to hijack this one.




BeTheBall -> RE: Odd Behaviour (5/15/2006 19:50:56)

Thanks for taking a look. It is a bit of a relief to know it's not just me.




jaybee -> RE: Odd Behaviour (5/15/2006 20:00:21)

quote:

Has to be an actual colour too - not just "inherit" or "transparent".


I've noticed that the warning errors you get from the css validator do the same thing. If you specify a color it's fine but if you use transparent or inherit it complains.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125