Problem with drop down

toolmania1

New Member
First issue:
I am using jquery and css for my drop downs. They work nicely except for one thing. I have a "Home" link. Under this "Home" link are some test links that do nothing for now ( I will make them real later after I get this last thing working ). Anyways, when I hover over the "Home" link, the drop down is displayed under it. If I move away from the "Home" link without moving my mouse over top of the drop down, the drop down never disappears since I never entered it. I have a 'hover' tag in my css for when the user does hover over the drop down. I will post the bulk of the code for this and see what you think:

html file:

( jquery part )
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(function(){
$('.dropdown').mouseenter(function(){
$('.sublinks').stop(false, true).hide();
var submenu = $(this).parent().next();
submenu.css({ position:'absolute',top: 20+'px',zIndex:1000,background:'white',left:0+'px', width:100+'px' });
submenu.stop().slideDown(300);
submenu.mouseleave(function(){ $(this).slideUp(300); }); }); });
</script>

( my "Home" link with drop down )
<ul>
<li><a href="./leetoniaIndex.html" class="dropdown" id="liBorder">Home</a></li>
<li class="sublinks">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
<a href="#">Link 4</a>
<a href="#">Link 5</a>
</li>
</ul><!--First Menu End -->
</div>

Now, in the css file:

ul
{
list-style:none;
padding:0px;
margin:0px;
}

ul li
{
display:inline;
float:left;
}

ul li a
{
text-decoration:none;
display:block;
}

ul li a:hover
{
text-decoration:none;
display:block;
}

ul li.sublinks a
{
text-decoration:none;
display:block;
border-style:solid;
border-width:1px;
}

ul li.sublinks a:hover
{
color:white;
background-color:blue;
}

ul li.sublinks
{
display:none;
}

Second issue:
I also would like the "Home" link to stay in its hover state while I have the mouse over any of the links in the drop down. The "Home" link will act as if the mouse has left the link. So, the "Home" link starts underlined, the underline is removed when I hover over the "Home" link, and then the underline returns when I hover over any of the links in the drop down. The "Home" link is not part of the class "sublinks" and I know this. I know this is why it is not behaving the same. But, for the jquery to work, I need the "Home" to be its own entity. So, maybe there is not way to have it stay in the non-underlined state while I am hovering over any of the links in the drop down.
 

AsheSkyler

New Member
I accomplished that on my site using just CSS back when I had a drop-down menu. I placed my navigation list inside a DIV named "nav" and this is the CSS I used this to style it:


#navigation
{background: url("/border-mid3.png") repeat-x bottom left; margin: 0px; padding: 0px;}

.nav
{width: 850px; height: 50px; margin: 5px auto 0px auto; padding: 20px 0px 2px 0px; text-align: center; font-size: 14px;}

.nav ul, .nav li
{text-indent: 5px; line-height: 25px; list-style-type: none; position: relative; display: block; float: center;}

.nav ul
{padding: 0px;}

.nav li
{top: -10px; left: 5px;}

.nav ul ul
{background-color: #FFFFFF; width: 275px; top: 35px; left: 0px; position: absolute; visibility: hidden; border: 1px solid #ADC9D4; border-radius: 10px; -moz-border-radius: 10px; text-align: left;}

.nav ul li
{max-width: 275px; top: -20px; left: 0px; padding: 5px; position: relative; display: block; float: left; list-style-type: none;}

.nav li, .nav li a, .nav li a:hover, .nav li a:hover
{max-width: 100px; min-height: 25px; padding: 0px; position: relative; display: block;}

.nav li li, .nav li li a, .nav li li a:hover, .nav li li a:focus
{min-width: 265px; top: 0px; position: relative; top: 0px: left: -5px;}

.nav ul li:hover ul, .nav ul li:focus ul
{visibility: visible;}

.nav ul li:hover, .nav ul li:focus
{background-color: #ADC9D4; border-radius: 10px; -moz-border-radius: 10px;}
 

toolmania1

New Member
Would this also have been the code for the html ( or something close to it ):

<div class=nav">
<ul>
<li>Hammers</li>
<ul>
<li>Big hammers</li>
<li>Medium hammers</li>
<li>Little hammers</li>
</ul>
</ul>

</div>
 

toolmania1

New Member
I accomplished that on my site using just CSS back when I had a drop-down menu. I placed my navigation list inside a DIV named "nav" and this is the CSS I used this to style it:


#navigation
{background: url("/border-mid3.png") repeat-x bottom left; margin: 0px; padding: 0px;}

.nav
{width: 850px; height: 50px; margin: 5px auto 0px auto; padding: 20px 0px 2px 0px; text-align: center; font-size: 14px;}

.nav ul, .nav li
{text-indent: 5px; line-height: 25px; list-style-type: none; position: relative; display: block; float: center;}

.nav ul
{padding: 0px;}

.nav li
{top: -10px; left: 5px;}

.nav ul ul
{background-color: #FFFFFF; width: 275px; top: 35px; left: 0px; position: absolute; visibility: hidden; border: 1px solid #ADC9D4; border-radius: 10px; -moz-border-radius: 10px; text-align: left;}

.nav ul li
{max-width: 275px; top: -20px; left: 0px; padding: 5px; position: relative; display: block; float: left; list-style-type: none;}

.nav li, .nav li a, .nav li a:hover, .nav li a:hover
{max-width: 100px; min-height: 25px; padding: 0px; position: relative; display: block;}

.nav li li, .nav li li a, .nav li li a:hover, .nav li li a:focus
{min-width: 265px; top: 0px; position: relative; top: 0px: left: -5px;}

.nav ul li:hover ul, .nav ul li:focus ul
{visibility: visible;}

.nav ul li:hover, .nav ul li:focus
{background-color: #ADC9D4; border-radius: 10px; -moz-border-radius: 10px;}

==========================

I put this code into a css file with the following html code. The word "Hammer" will turn red when I hover over it. But, the items underneath do not show up. I even turned them different colors to see if they would be there and they still were not.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Leetonia Community Public Library</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="dropDownCSS.css" rel="stylesheet" type="text/css">

</head>

<body>
<div id="navigation">

<div class="nav">
<ul>
<li><a href="#">Hammers</a></li>
<ul>
<li><a href="#">Big hammers</a></li>
<li><a href="#">Medium hammers</a></li>
<li><a href="#">Little hammers</a></li>
</ul>
</ul>

</div>

</div>

</body>
</html>


Furthermore, if I changed visibility to visible for this:

.nav ul ul
{background-color: yellow; width: 150px; top: 35px; left: 0px; position: absolute; visibility: visible; border: 1px solid #ADC9D4; border-radius: 10px; -moz-border-radius: 10px; text-align: left;}

I can see these:

<li><a href="#">Big hammers</a></li>
<li><a href="#">Medium hammers</a></li>
<li><a href="#">Little hammers</a></li>

show in the browser where they would normally be for a drop down underneath the word "Hammer".

As soon as I put that back to this:

.nav ul ul
{background-color: yellow; width: 150px; top: 35px; left: 0px; position: absolute; visibility: hidden; border: 1px solid #ADC9D4; border-radius: 10px; -moz-border-radius: 10px; text-align: left;}

where "visibility:hidden" is now the code, then I never see the "Big hammers", "Medium hammers", "Little hammers" show up underneath "Hammers".
 

toolmania1

New Member
That worked perfectly. Thanks for the link. I have tried many other drop downs from other sites that say they work. But, this was the first to ACTUALLY work. The other one posted above I think may have been one tweak of the code from working. I still wouldn't mind also getting that to work. Anyways, thanks!
 

toolmania1

New Member
Well, let me ammend my last statement. This works perfectly in Firefox. In IE, I can see the sub options that are supposed to be hidden until hover. I think this is why I went with jquery because IE did not complain like it is doing with my css drop downs.
 

AsheSkyler

New Member
My error, I completely forgot the HTML list half. It's exactly like the one in the link by Ronald where you embed a list inside one of the items.

The last time I ran a test I had the dropdown working in IE, Firefox, Chrome, Opera, and Safari, but I wasn't able to test old browsers.
 

toolmania1

New Member
I apologize, but I just want to make sure I am understanding everything correctly. Could someone post their full html page with the full css page here that works in IE9 when it was tested today? This could even be just a barebones minimum that has the drop downs working in IE9. It doesn't have to be a page off of a working web site.

In IE9, today, for me, nothing posted on this page so far works. Are there special settings maybe in IE9 that also need set? I went to Ronald's site and his site does in fact show up correctly in IE9 for me, today. I opened Firebug and tried to copy the code and put it into html and css files. In Firefox, once again, I got it to show perfectly. Once again, in IE9, it would not show up correctly.

I would gather from this that my IE9 settings are fine since they did display ronald's site that he posted in his link.

***grrr *** <<< pulls hair out <<< not really, :)
 

AsheSkyler

New Member
Heheh, I had similar problems trying to make a "sticky footer". Worked on everybody's site but mine for no apparent reason.

I just upgraded to IE9 today and made no modifications to the settings. As barebones as possible, this is something I had that worked:

CSS
.nav
{margin: 0px auto; padding: 00px;}

.nav ul, .nav li
{line-height: 25px; list-style-type: none; position: relative; display: block;}

.nav ul
{padding: 0px;}

.nav li
{top: -10px; left: 5px;}

.nav ul ul
{background-color: #88AADD; top: 35px; left: 0px; position: absolute; visibility: hidden;}

.nav ul li
{left: 0px; padding: 5px; position: relative; display: block; float: left; list-style-type: none;}

.nav li, .nav li a, .nav li a:hover, .nav li a:hover
{min-width: 50px; min-height: 25px; padding: 0px; position: relative; display: block;}

.nav li li, .nav li li a, .nav li li a:hover, .nav li li a:focus
{position: relative; top: 0px; left: 0px;}

.nav ul li:hover ul, .nav ul li:focus ul
{visibility: visible;}

.nav ul li:hover, .nav ul li:focus
{background-color: #ADC9D4;}

HTML
<div class="nav">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Archive</a>
<ul>
<li><a href="">News</a></li>
<li><a href="">Blog</a></li>
</ul>
</li>
<li><a href="">About</a></li>
</ul>
</div> <!-- /.nav -->

Main site that I modified it from is here, if that's any help.
 

toolmania1

New Member
Thanks!

Ya, something must be up. I am at home now ( a different computer than my work pc ) and the same thing. So, I restored IE9 back to the default settings. I copied the code you gave me. I put the html into a .html file and the css into a .css. I added the appropriate tags so that I had these 2 files exactly:

======== html file =======

<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="TestCSS.css" rel="stylesheet" type="text/css">
</head>

<body>

<div class="nav">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Archive</a>
<ul>
<li><a href="">News</a></li>
<li><a href="">Blog</a></li>
</ul>
</li>
<li><a href="">About</a></li>
</ul>
</div> <!-- /.nav -->

</body>
</html>

======= css file =======

.nav
{margin: 0px auto; padding: 00px;}

.nav ul, .nav li
{line-height: 25px; list-style-type: none; position: relative; display: block;}

.nav ul
{padding: 0px;}

.nav li
{top: -10px; left: 5px;}

.nav ul ul
{background-color: #88AADD; top: 35px; left: 0px; position: absolute; visibility: hidden;}

.nav ul li
{left: 0px; padding: 5px; position: relative; display: block; float: left; list-style-type: none;}

.nav li, .nav li a, .nav li a:hover, .nav li a:hover
{min-width: 50px; min-height: 25px; padding: 0px; position: relative; display: block;}

.nav li li, .nav li li a, .nav li li a:hover, .nav li li a:focus
{position: relative; top: 0px; left: 0px;}

.nav ul li:hover ul, .nav ul li:focus ul
{visibility: visible;}

.nav ul li:hover, .nav ul li:focus
{background-color: #ADC9D4;}

===============

There has to be something going on that is not allowing IE9 to show this correctly. I am baffled though since Firefox shows it perfectly.

Oh, I am using Notepad++ to "Run in Firefox" and "Run in IE9". However, I did just navigate through windows explorer and "Open with Firefox" and "Open with Internet Explorer" and the same thing happened.
 

AsheSkyler

New Member
Ah, now THAT doesn't work in my IE9. The part that's throwing it off is:
===
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
===

Are you able to use <!DOCTYPE HTML><html> instead, or would that completely mess up the page you're working on?
 

toolmania1

New Member
Wow!

I did not realize that this was the problem:

<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

I removed that and put what you suggested:

<!DOCTYPE HTML><html>

leaving everything else the same as my last post. The drop down worked in IE9. I knew it was something simple.

Ok, so I understand what is happening, what was wrong with what I had? I will have to google this anyways to see what that means. I think I just copied it from someone because I obviously cannot explain what it means right now...lol.

Anyways, thanks for the help. This would probably explain how none of the other solutions were working for me either. :D
 
Top