/    Sign up×
Community /Pin to ProfileBookmark

css drop menu problem

Hi
I have searched this forum for this issue, and have found many threads with explanation. I have tried all of them, but it does not work.
My problem is that my css drop down menu works in firefox, but not in ie7. The site is [url]http://redesign.des-us.com/[/url], and this concerns the top menu. The code I am using is this:

[code=html]
<div id=”topmenu”>
<ul>
<li><a href=”index.asp”>Home </a><img src=”images/seperator.gif” width=”5″ height=”5″ /></li>
<li><a href=”about.asp”>About Us </a><img src=”images/seperator.gif” width=”5″ height=”5″ /></li>
<li><a href=”web.asp”>Web </a><img src=”images/seperator.gif” width=”5″ height=”5″ />
<ul id=”subnav”>
<li>| <a href=”webservices.asp#design”>Design</a> | </li>
<li><a href=”webservices.asp#dev”>Applications</a> | </li>
<li><a href=”webservices.asp#graphics”>Graphics</a> | </li>
<li><a href=”webservices.asp#other”>Services</a> |</li>
</ul>
</li>
<li><a href=”erp.asp”>ERP </a><img src=”images/seperator.gif” width=”5″ height=”5″ /></li>
<li><a href=”portfolio.asp”>Portfolio </a><img src=”images/seperator.gif” width=”5″ height=”5″ />
<ul id=”subnav”>
<li>|<a href=”#”> ERP</a> | </li>
<li><a href=”#”>Design</a> | </li>
<li><a href=”#”>Application</a> | </li>
<li><a href=”#”>Templates</a> | </li>
<li><a href=”#”>Office Docs </a> |</li>
</ul>
</li>
<li><a href=”resources.asp”>Resources </a><img src=”images/seperator.gif” width=”5″ height=”5″ />
<ul id=”subnav”>
<li>|<a href=”resources.php”> Links</a> | </li>
<li><a href=”templates.htm”>Templates</a> | </li>
<li><a href=”articles.php”>Articles</a> | </li>
<li><a href=”jobs.htm”>Employment</a> | </li>
<li><a href=”blog.des-us.com”>Blog </a> |</li>
</ul>
</li>
<li><a href=”contact.asp”>Contact </a><img src=”images/seperator.gif” width=”5″ height=”5″ /></li>
<!– combine contact and feedback forms –>
<li><a href=”sitemap.asp”>Site Map</a> </li>
</ul>
</div>
[/code]

The css is:

[CODE]
#topmenu {text-align:right;}
/* 1st level */
#topmenu ul {padding:0; margin:0; list-style:none; position:relative;}
#topmenu ul li {display:inline; padding:3px; border-bottom:thin solid #F99400;}
#topmenu ul li a, a:hover, a:visited {color:#FFFFFF; text-decoration:none;}

/*2nd level */
#topmenu ul ul {position:absolute;top:25px; left:30%; text-align:right; display:none; width:auto;}
#topmenu li:hover ul#subnav, #topmenu li.over ul#subnav {display:block;}
#topmenu li:hover ul#subnav li a, #topmenu li:hover ul#subnav li a:hover {padding:2px;}
[/CODE]

The javascript is:

[CODE]
// JavaScript Document
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById(“topmenu”);
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;
[/CODE]

Can anyone please help me?

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisFeb 21.2008 — if (node.nodeName=="LI") {[/quote]
Try this:
if (node.nodeName.toUpperCase() == "LI") {
Copy linkTweet thisAlerts:
@tasneemauthorFeb 21.2008 — Hi

Thanks. This works haphazardly in IE, but atleast it works ? I have to be very quick to click on the drop down menu, otherwise, it doesnt work. If there is any other option, I would like to try it.

Thanks
Copy linkTweet thisAlerts:
@CentauriFeb 21.2008 — The main problem here is the "top" value of the absolutely positioned dropdown <ul>s - there is a gap between the dropdown and the top level <li> which causes the dropout. Setting the top position of the dropdown in ems (to allow for text resize) and closing up the gap will get it working :[CODE]#topmenu ul ul {position:absolute;top:[COLOR="Red"]1.5em[/COLOR]; left:30%; text-align:right; display:none; width:auto;}[/CODE]

I would also recommend replacing that hover javascript with the one presented here - works much better and is cleaner (you will have to change the id name and the added class name to match your names).

I would also recommend the swfobject script (Google it) for embedding flash instead of that AC_RunActiveContent script too.
Copy linkTweet thisAlerts:
@tasneemauthorMar 05.2008 — Hi

Using swfobject now.

for the top menu, the problem still persists after using the suckerfish javascript and css.

thanks
Copy linkTweet thisAlerts:
@CentauriMar 06.2008 — A background colour on the dropdown <ul> sometimes helps IE along :[CODE]#topmenu li:hover ul#subnav, #topmenu li.over ul#subnav {display:block; [COLOR="Red"]background-color: #8499FA;[/COLOR]}[/CODE]
×

Success!

Help @tasneem spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...