/    Sign up×
Community /Pin to ProfileBookmark

Help customizing CSS menu

Hi, I’m using the CSS Top Menu from Javascript Kit and trying to customize it. The problem I have is that I want the menu drop-downs to be separate from the header links (not much separation, but more than the default setting), but if I set the “top” attribute in submenus style to great than 1.4 em, the menus will display, then behave strangely (can’t select the contents, etc.) I also need to modify this so the menus will be separate in Firefox and other non-IE browsers. So I’m looking for a solution. Any ideas?

Here’s my code so far:

[CODE]<style type=”text/css”>

#csstopmenu, #csstopmenu ul{
padding: 0;
margin: 0;
list-style: none;
}

#csstopmenu li{
float: left;
position: relative;
}

#csstopmenu a{
text-decoration: none;
}

.mainitems{
border-right: 1px solid #cccccc;
border-bottom: 1px solid #cccccc;
border-left-width: 0;
background-color: #ffffff;
font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000000;
}

.headerlinks {
margin: auto 8px;
font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000000;
color: black;}

.headerlinks a:hover{
background-color: #ffffff;
color: #FF0000;
}

.submenus{
display: none;
width: 15em;
position: absolute;
top: 1.4em;
left: 0;
background-color: #f6f6f6;
border-right: 1px solid #cccccc;
border-bottom: 1px solid #cccccc;
border-left: 1px solid #cccccc;
font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-weight: normal; color: #000000;
}

.submenus li{
width: 100%;
}

.submenus li a{
display: block;
width: 100%;
text-indent: 8px;
}

html>body .submenus li a{ /* non IE browsers */
width: auto;
}

.submenus li a:hover{
background-color: #f6f6f6;
color: #FF0000;
}

#csstopmenu li>ul {/* non IE browsers */
top: auto;
left: auto;
}

#csstopmenu li:hover ul, li.over ul {
display: block;
}

html>body #clearmenu{ /* non IE browsers */
height: 3px;
}
</style>

<script type=”text/javascript”>

// CSS Top Menu- By JavaScriptKit.com (http://www.javascriptkit.com)
// Adopted from SuckerFish menu
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// Please keep this credit intact

startMenu = function() {
if (document.all&&document.getElementById) {
cssmenu = document.getElementById(“csstopmenu”);
for (i=0; i<cssmenu.childNodes.length; i++) {
node = cssmenu.childNodes[i];
if (node.nodeName==”LI”) {
node.onmouseover=function() {
this.className+=” over”;
}
node.onmouseout=function(){
this.className=this.className.replace(” over”, “”)
}
}
}
}
}

if (window.attachEvent)
window.attachEvent(“onload”, startMenu)
else
window.onload=startMenu;

</script>
</head>

<body>
<ul id=”csstopmenu”>

<li class=”mainitems” style=”border-left-width: 1px”>
<div class=”headerlinks”><a href=”http://www.javascriptkit.com”>JavaScript Kit</a></div>
<ul class=”submenus”>
<li><a href=”http://javascriptkit.com/”>Home</a></li>
<li><a href=”http://javascriptkit.com/cutpastejava.shtml”>Free JavaScripts</a></li>
<li><a href=”http://javascriptkit.com/javaindex.shtml”>JavaScript tutorials</a></li>
<li><a href=”http://javascriptkit.com/jsref/index.shtml”>JavaScript Reference</a></li>
</ul>
</li>

<li class=”mainitems”>
<div class=”headerlinks”><a href=”http://www.javascriptkit.com”>2nd Menu Item</a></div>
<ul class=”submenus” style=”width: 14em”>
<li><a href=””>Sub 2 Item 1. Long text, long menu.</a></li>
<li><a href=””>Sub 2 Item 2</a></li>
<li><a href=””>Sub 2 Item 3.</a></li>
</ul>
</li>

<li class=”mainitems”>
<div class=”headerlinks”><a href=”http://www.javascriptkit.com”>3rd Menu Item</a></div>
<ul class=”submenus”>
<li><a href=””>Sub 3 Item 1</a></li>
<li><a href=””>Sub 3 Item 1</a></li>
<li><a href=””>Sub 3 Item 1</a></li>
<li><a href=””>Sub 3 Item 1</a></li>
</ul>
</li>

</ul>[/CODE]

Thanks for any help ?

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@WofenJun 15.2005 — That is quite a messy script( at lest IMO). There is a great drop down menu system that I use.

Click [URL=http://www.alistapart.com/articles/dropdowns/]Here[/URL] to see a demo.

Its a nice and simple script to use.

If you dont like that one, I use a pure Java script menu system. I dont have a howto page on it, but the script can be located [URL=http://www.gslc.qld.edu.au/newpage/gslc(noosa(text))/index.htm]Here[/URL].

Also, I would like to help with your problem(rather then just give options to get around it), but I cant see the error without seeing the page. Can you please post a link for the webpage.

Wofen

PS: The link should be fixed.
Copy linkTweet thisAlerts:
@bkdell11authorJun 15.2005 — Thanks for the reply

The 2nd link you provided doesn't work, can you repost maybe?

The script I'm using now is eerily similar to the ALA one you linked me to. It uses the same javascript (just changes some names). If you copy and paste the code I posted into a blank HTML doc and just view it locally, you should be able to see the issue. Trying change to "top" attribute in submenus to 1.6 and you won't be able to select any of the drop-down menu contents, the menus flicker on and off. Can't figure out what causes that.

Thanks
Copy linkTweet thisAlerts:
@JayhawkJun 15.2005 — As soon as your mouse leaves the menu on its way to the way to the submenu the submenu turns off (or tries to). The submenus have to have to be nearly contiguous to the main menu so that the cursor doesn't lose cont act.
Copy linkTweet thisAlerts:
@WofenJun 15.2005 — Oh, if thats the problem(It would be easyer with a web page), Change the padding. I am not 100% sure that it would work on this example(I really want a example), but I know in alot of the CSS menu systems out there can use the padding to extend the box that the mouse is considered over the box.

Wofen
×

Success!

Help @bkdell11 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.16,
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,
)...