...

View Full Version : Drop down menu IE6



tktrn99
02-02-2007, 01:17 AM
OK guys, I'm still fairly new at this, so please be patient. I have built a drop down menu that works fine in IE7 and FF, but I cannot get the submenus to appear in EI6. I have found on the web various problems that would cause this, but can't find a solution - I've edited, and re-edited with no use. Any help would be great!

Code follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="/styles/front.css" rel="stylesheet" type="text/css" />
<ul id="div">
<style>
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;
</style>
<title>Simply My Sims</title>
</head>
<body>
<div id="wrapper">
<div id="header">
<img src="/images/head.jpg" />
<h1>&raquo; Simply My Sims &laquo; </h1>
<h2>My little piece of the Sims 2 world...</h2>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div id="nav">
<ul>
<li><a href="/" title="home">Home</a>
<ul>
<li><a href="/aboutme.html" title="aboutme">About Me</a></li>
</ul>
</li>
<li><a href="/" title="challenges">Challenges</a>
<ul>
<li><a href="/legacy/intro.html" title="legacy">Whitmore Legacy</a></li>
<li><a href="/dhw/intro.html" title="dhw">Desperate Housewife</a></li>
<li><a href="http://tktrn99.blogsome.com/" title="widow">Black Widow</a></li>
<li><a href="http://tktrn99-twins.blogspot.com/" title="twins">Twin Experiment</a></li>
</ul>
</li>
<li><a href="/" title="links">Links</a>
<ul>
<li><a href="/links/stories.html" title="stories">Sim Stories</a></li>
<li><a href="/links/cc.html" title="cc">Custom Content</a></li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>

CSS:
body {
font-family: Georgia, "Times New Roman", Times, serif;
background:url(/images/mistytil.jpg);
text-align: left;
}
#wrapper {
width: 800px;
margin: 0 auto;
padding: 0;
text-align: left;
background-color: #FFFFFF;
}
#header {
color: #C71585;
text-align: center;
height: 200px;
font-family: DiMurphic;
}
#header img {
position: relative;
text-align: left;
float: left;
}
#nav {
border: 5px #6495ED solid;
width: 150px;
}
#nav ul {
margin: 0;
padding: 0;
list-style: none;
width: 150px;
border-bottom: 1px solid #ccc;
}
#nav ul li {
position: relative;
}
#nav li ul {
position: absolute;
left: 145px;
top: 0;
display: none;
}
#nav ul li a {
display: block;
text-decoration: none;
color: #FFFFFF;
background: #4682B4;
padding: 5px;
border: 1px solid #6495ED;
border-bottom: 0;
}
#nav li:hover ul, li.over ul {
display: block;
}

/* Fix IE. Hide from IE Mac \*/
* html ul li { float: left; }
* html ul li a { height: 1%; }
/* End */

#main-content {
border: 5px #A0522D solid;
padding: 50px;
}
#main-text {
border: 5px #DAA520 dashed;
}
#footer {
background-color: #DEB887;
border: 5px #808080 solid;
text-align:center;
}

butlins
02-02-2007, 12:41 PM
I'm assuming that the bit of script in the <style> tag at the top looks like it should be in a <script language="javascript" type="text/javascript"> tag, and there's some strange ordering of code with a <ul> in the middle of your <head>, which I'm assuming is a typo. At least I hope it's not deliberate, or we'll have to send you back to HTML 101... ;)

Also, when you post, it's customary to tag your code - if you look in the line of style icons at the top of the form you use to post, you'll see a '#' icon which wraps code tags around it.

butlins
02-02-2007, 01:16 PM
This is based on the Son of Suckerfish method (http://www.htmldog.com/articles/suckerfish/dropdowns/), from HTML Dog which is my personal favourite method.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simply My Sims</title>
<style type="text/css">
body {
font-family: Georgia, "Times New Roman", Times, serif;
background:url(/images/mistytil.jpg);
text-align: left;
}
#wrapper {
width: 800px;
margin: 0 auto;
padding: 0;
text-align: left;
background-color: #FFFFFF;
}
#header {
color: #C71585;
text-align: center;
height: 200px;
font-family: DiMurphic;
}
#header img {
position: relative;
text-align: left;
float: left;
}

#nav, #nav ul { /* all lists */
padding: 0;
margin: 0;
list-style: none;
float : left;
width : 150px;
}

#nav ul{
border: 5px #6495ED solid;
}

#nav li { /* all list items */
position : relative;
float : left;
line-height : 1.25em;
margin-bottom : -1px;
width: 150px;
}

#nav li ul { /* second-level lists */
position : absolute;
left: -999em;
margin-left : 150px;
margin-top : -2em;
border: 0;
border-bottom: 1px solid #ccc;
}

#nav li a {
width: 150px;
w\idth : 140px;
display : block;
color : #FFFFFF;
text-decoration : none;
background-color : #4682B4;
padding: 5px;
border: 1px solid #6495ED;
border-bottom: 0;
}

#nav li a:hover {
color : white;
background-color : black;
}

#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 { /* lists nested under hovered list items */
left: auto;
}

#content {
margin-left : 12em;
}
</style>
<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>
</head>
<body>
<div id="wrapper">
<div id="header"> <img src="/images/head.jpg" />
<h1>&raquo; Simply My Sims &laquo; </h1>
<h2>My little piece of the Sims 2 world...</h2>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div id="nav">
<ul>
<li><a href="/" title="home">Home</a>
<ul>
<li><a href="/aboutme.html" title="aboutme">About Me</a></li>
</ul>
</li>
<li><a href="/" title="challenges">Challenges</a>
<ul>
<li><a href="/legacy/intro.html" title="legacy">Whitmore Legacy</a></li>
<li><a href="/dhw/intro.html" title="dhw">Desperate Housewife</a></li>
<li><a href="http://tktrn99.blogsome.com/" title="widow">Black Widow</a></li>
<li><a href="http://tktrn99-twins.blogspot.com/" title="twins">Twin
Experiment</a></li>
</ul>
</li>
<li><a href="/" title="links">Links</a>
<ul>
<li><a href="/links/stories.html" title="stories">Sim Stories</a></li>
<li><a href="/links/cc.html" title="cc">Custom Content</a></li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>


I think there's tiny bit of tweaking with the border around the navigation to be done - looks a tiny bit off at the moment. I'm going to pretend that that was deliberate and that's your homework to finish a little bit of CSS debugging.

tktrn99
02-02-2007, 05:10 PM
Thank you so much! Works beautifully in IE6 now. In IE7 the submenus are left hanging once you scroll over them. Do I need to move them to the right a few pixels to prevent this? Take a look..
http://www.simplymysims.com/front.php
Thanks again!!

butlins
02-02-2007, 08:25 PM
Afraid I'm Mac-based at home, so I can't check now until after the weekend. I did check in IE7 before I left, and it looked okay, but I was concentrating on IE6, so my bad.

I must admit, I thought there would be a few issues, as I rushed a bit, and was mixing ems (from the Son of Suckerfish article) and pixels (from your basic code) as I went. It's likely that just a tiny bit of tweaking will work fine.

To make sure that you don't affect the implementation in FF and IE6, create a new style sheet (say 'ie7.css'), and wrap the link to it in a conditional comment. You can then make edits to the CSS that will only affect IE7.

I hope you don't mind if I leave you to research the use of conditional comments as part of your 'homework'.

tktrn99
02-02-2007, 10:32 PM
Thanks again for helping. Seems this is a son of suckerfish bug found only in IE7 - found an easy solution here: http://www.builtfromsource.com/2006/10/23/a-fix-for-suckerfish-dropdowns-in-ie-7/

Thanks again!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum