Log in

View Full Version : CSS Drop down menu glitch/error?



sexayenicole
12-29-2008, 06:40 AM
Hi guys, really need help with this drop down menu issue I have for my personal blog archives.

The drop down menu consists of a Top Level: (Archives)
And a Second Level: 2008
And sub levels under that : Jan, Feb, Mar etc.

Therefore, it should be: Archives (Hover over and you will see 2008), and then when 2008 appears, (Hover over 2008 and the different months appear).

However, what's happening now is whenever I hover over Archives, EVERYTHING shows at once. I've been trying to fiddle around with it and I still dont get it.

The code below is:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>· Immaculate Recherche. ·</title>
<meta name="Author" content="Stu Nicholls" />
<meta name="Keywords" content="cssplay, css, play, Cascading, Style, Sheets, opacity, layouts, navigation, menus, experiments,demonstrations, photo, photograph, gallery, slide, slideshow, picture, drop, down, pull, up, fly, out, free" />
<meta name="Description" content="CSS - Cutting edge Cascading Style Sheets. Experiments in CSS" />
<meta name="verify-v1" content="n3Dpx4NklZjg5p/Tq7h1q+Oj6Ml83crtkO/PwepVQ6Y=" />
<meta http-equiv="imagetoolbar" content="no" />


<link rel="meta" href="http://www.cssplay.co.uk/labels.rdf" type="application/rdf+xml" title="ICRA labels" />
<meta http-equiv="pics-Label" content='(pics-1.1 "http://www.icra.org/pics/vocabularyv03/" l gen true for "http://cssplay.co.uk" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 0) gen true for "http://www.cssplay.co.uk" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 0))' />

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.cssplay.co.uk/feed.xml" />
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<link rel="icon" href="../favicon.ico" type="image/ico" />
<link rel="stylesheet" media="all" type="text/css" href="../css/css_play4.css" />
<style type="text/css">
@import url(http://www.google.com/cse/api/branding.css);
#search {width:360px; top:10px; float:right; text-align:right;}
</style>
<link rel="stylesheet" media="all" type="text/css" href="../css/menus.css" />

<style type="text/css">


/* ================================================================
This copyright notice must be untouched at all times.

The original version of this stylesheet and the associated (x)html
is available at http://www.cssplay.co.uk/menus/final_drop.html
Copyright (c) 2005-2008 Stu Nicholls. All rights reserved.
This stylesheet and the associated (x)html may be modified in any
way to fit your requirements.
=================================================================== */

.menu {width:745px; height:32px; position:absolute; left: 232px; z-index:100;border-right:1px solid #000; font-family:arial, sans-serif;}
/* hack to correct IE5.5 faulty box model */
* html .menu {width:746px; w\idth:745px;}
/* remove all the bullets, borders and padding from the default list styling */
.menu ul {padding:0;margin:0;list-style-type:none;}
.menu ul ul {width:149px;}
/* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */
.menu li {float:left;width:149px;position:relative;}
/* style the links for the top level */
.menu a, .menu a:visited {display:block;font-size:12px;text-decoration:none; color: #FF9999; text-align:center; width:146px; height:30px; border:1px solid #000; border-width:1px 0 1px 1px; background:#333333; padding-left:1px; line-height:29px; font-weight:bold;}
/* a hack so that IE5.5 faulty box model is corrected */
* html .menu a, * html .menu a:visited {width:149px; w\idth:138px;}

/* style the second level background */
.menu ul ul a.drop, .menu ul ul a.drop:visited {background:#333333 url(http://www.cssplay.co.uk/menus/breadcrumbs/grey-arrow.gif) no-repeat 130px center;}
/* style the second level hover */
.menu ul ul a.drop:hover{background:#FF9999 url(http://www.cssplay.co.uk/menus/breadcrumbs/blue-arrow.gif) no-repeat 130px center;}
.menu ul ul :hover > a.drop {background:#FF9999 url(http://www.cssplay.co.uk/menus/breadcrumbs/blue-arrow.gif) no-repeat 130px center;}
/* style the third level background */
.menu ul ul ul a, .menu ul ul ul a:visited {background:#333333;}
/* style the third level hover */
.menu ul ul ul a:hover {background:#b2ab9b;}


/* hide the sub levels and give them a positon absolute so that they take up no room */
.menu ul ul {visibility:hidden;position:absolute;height:0;top:31px;left:0; width:149px;border-top:1px solid #000;}
/* another hack for IE5.5 */
* html .menu ul ul {top:30px;t\op:31px;}

/* position the third level flyout menu */
.menu ul ul ul{left:149px; top:-1px; width:149px;}

/* position the third level flyout menu for a left flyout */
.menu ul ul ul.left {left:-149px;}

/* style the table so that it takes no ppart in the layout - required for IE to work */
.menu table {position:absolute; top:0; left:0; border-collapse:collapse;;}

/* style the second level links */
.menu ul ul a, .menu ul ul a:visited {background:#d4d8bd; color:#A3A3A3; height:auto; line-height:1em; padding:5px 10px; width:128px;border-width:0 1px 1px 1px;}
/* yet another hack for IE5.5 */
* html .menu ul ul a, * html .menu ul ul a:visited {width:150px;w\idth:128px;}

/* style the top level hover */
.menu a:hover, .menu ul ul a:hover{color:#000; background:#FF9999;}
.menu :hover > a, .menu ul ul :hover > a {color:#000; background:#FF9999;}

/* make the second level visible when hover on first level list OR link */
.menu ul li:hover ul,
.menu ul a:hover ul{visibility:visible;}
/* keep the third level hidden when you hover on first level list OR link */
.menu ul :hover ul ul{visibility:hidden;}
/* make the third level visible when you hover over second level list OR link */
.menu ul :hover ul :hover ul{visibility:hidden;}

</style>



<div class="menu">
<ul>
<li><a href="../">Archives<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>

<li><a class="drop" href="../">2008<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>

<li><a href="../2008_01_01_blacksaccharine_archive.html">January</a></li>
<li><a href="../2008_02_01_blacksaccharine_archive.html">February</a></li>
<li><a href="../2008_03_01_blacksaccharine_archive.html">March</a></li>
<li><a href="../2008_04_01_blacksaccharine_archive.html">April</a></li>
<li><a href="../2008_05_01_blacksaccharine_archive.html">May</a></li>
<li><a href="../2008_06_01_blacksaccharine_archive.html">June</a></li>
<li><a href="../2008_07_01_blacksaccharine_archive.html">July</a></li>
<li><a href="../2008_08_01_blacksaccharine_archive.html">August</a></li>
<li><a href="../2008_09_01_blacksaccharine_archive.html">September</a></li>
<li><a href="../2008_10_01_blacksaccharine_archive.html">October</a></li>
<li><a href="../2008_11_01_blacksaccharine_archive.html">November</a></li>
<li><a href="../2008_12_01_blacksaccharine_archive.html">December</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
</ul>

</div>


Thank you.

bluewalrus
12-29-2008, 07:04 AM
When i test that code it displays archives then 2008 only on mouse over, do you have a link where this is online... or where the whole code is?

sexayenicole
12-29-2008, 07:05 AM
When i test that code it displays archives then 2008 only on mouse over, do you have a link where this is online... or where the whole code is?

The link is: http://blacksaccharine.blogspot.com

It's driving me crazy! :confused:

I have not tested it out in IE yet, using Firefox now. So I'm not sure if it's the same in IE.

bluewalrus
12-29-2008, 07:18 AM
This should do it...

.menu ul li ul li ul a {visibility:hidden;}
.menu ul li ul li:hover ul a{ visibility:visible;}

sexayenicole
12-29-2008, 07:21 AM
This should do it...

.menu ul li ul li ul a {visibility:hidden;}
.menu ul li ul li:hover ul a{ visibility:visible;}

Omg you're brilliant!
Thank you so much!!! :)

sexayenicole
12-29-2008, 07:40 AM
Oh dear. I just realised that it doesnt work in IE, though it was supposed to.

Is there a way to make it both IE and FF compatible?

bluewalrus
12-29-2008, 04:34 PM
Yea you need a conditional statement for IE it doesn't read the li hover, it only accepts a:hover. I thought you had a conditional statement though because the first one worked didn't it? Give this a try...http://www.alistapart.com/articles/dropdowns . If you can't find it there hit ctrl (apple) + f, and then enter
Hold on a minute!

sexayenicole
12-30-2008, 02:57 AM
Yea you need a conditional statement for IE it doesn't read the li hover, it only accepts a:hover. I thought you had a conditional statement though because the first one worked didn't it? Give this a try...http://www.alistapart.com/articles/dropdowns . If you can't find it there hit ctrl (apple) + f, and then enter

Confused =(

bluewalrus
12-30-2008, 03:00 AM
from the article or what i said?

sexayenicole
12-30-2008, 03:01 AM
from the article or what i said?

From the article, and how to edit and incorporate it into my template.

bluewalrus
12-30-2008, 03:06 AM
The conditional statement tests to see if a condition is meet in this case if the browser is internet explorer. Internet Explorer does not allow the hover state I used on elements other the a(the link's tag) (I used it on an li which is a line item from your unordered list). I thought since you already had these as hovered there was already a conditional statement testing if ie was the browser and if so setting it to be able to be hovered. That link should explain how to set up one though if (which it appears you do not) have one.

This will be javascript and will go in the head of your document.

bluewalrus
12-30-2008, 03:11 AM
use this

<script type="text/javascript"><!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;

//--><!]]></script>

then add this in place of the second line I gave you last night...

.menu ul li ul li:hover ul a, .menu ul li ul li.over ul a{ visibility:visible;}

sexayenicole
12-30-2008, 03:20 AM
use this

<script type="text/javascript"><!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;

//--><!]]></script>

then add this in place of the second line I gave you last night...

.menu ul li ul li:hover ul a, .menu ul li ul li.over ul a{ visibility:visible;}

Hmmm. Did exactly what you said. Still doesn't work..

bluewalrus
12-30-2008, 03:32 AM
Well I don't know then I don't have ie and I just code waiting for someone with ie to say whats wrong then code backwards till its good (very not the best way but ie5.2 is not accurate representer of ie in anyway and they stopped making it for mac so out of luck for the time being). Doesn't always work. You could wait for someone else to respond back here with more knowledge of ie.

I thought that method worked though I used it on another page that has ie users and I have only heard that it works (thus far). Try this and see if the drop down here works http://www.htmldog.com/articles/suckerfish/bones/

bluewalrus
12-30-2008, 06:33 AM
I'm just gonna keep giving similar scripts i find until it works or someone else gives you one that actually works...


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

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>



.menu ul li ul li:hover ul a, .menu ul li ul li.sfhover ul a{ visibility:visible;}

sexayenicole
12-30-2008, 08:25 AM
I'm just gonna keep giving similar scripts i find until it works or someone else gives you one that actually works...


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

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>



.menu ul li ul li:hover ul a, .menu ul li ul li.sfhover ul a{ visibility:visible;}

Just tried. Still the same. Sigh I wish I were an IT genius.

bluewalrus
01-06-2009, 05:00 AM
What version of IE are you using, if you look at my test this menu please thread probably below this I've been working with some other users to get the drop down (-over) menu to work in IE and have it relatively working in IE 7 now.

TheJoshMan
01-07-2009, 02:38 AM
There's a much easier way to make IE recognize the :hover pseudo class on more than just anchor tags...

Rather than adding that piece of script and adding a ton of extra css... Why not just use this:



<!--[if lt IE 7]>
<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script>
<![endif]-->



Just place that between the <head> and </head> tags in your page and you're done.

sexayenicole
01-10-2009, 01:30 PM
It only works in FF. I'm using IE 7. I've replaced the archives with a typical old drop down menu. so far its working fine in both sides, although the one i mentioned in this thread looks much nicer.