Hi guys,
Recently I was looking for a nice js/css dropdown menu. I found a great one, problem is: I can’t get it centered on my page and it looks awful this way…
Little screenshot of how it looks now is included in attachment.
This is the code for the menu itself (html):
<div id="sddm-container">
<ul id="sddm">
<li><a href="#">Overview</a></li>
<li><a href="#"
onmouseover="mopen('m1')"
onmouseout="mclosetime()">Config</a>
<div id="m1"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="#">Test</a>
<a href="#">Test</a>
<a href="#">Test</a>
</div>
</li>
<li><a href="#"
onmouseover="mopen('m2')"
onmouseout="mclosetime()">Battle</a>
<div id="m2"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="#">Test</a>
<a href="#">Test</a>
</div>
</li>
<li><a href="#"
onmouseover="mopen('m3')"
onmouseout="mclosetime()">Specifics</a>
<div id="m3"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="#">Test</a>
<a href="#">Test</a>
</div>
</li>
<li><a href="#"
onmouseover="mopen('m4')"
onmouseout="mclosetime()">Technical</a>
<div id="m4"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="#">Test</a>
<a href="#">Test</a>
</div>
</li>
</ul>
<div style="clear:both"></div></div>
The CSS code:
#sddm
{ margin: 0;
padding: 0;
z-index: 30}
#navcontainer
{
margin-right: auto;
margin-left: auto;
padding: 0px 0px 0px 0px;
}
#sddm li
{ margin: 0;
padding: 0;
list-style: none;
float: left;
font: bold 11px arial}
#sddm li a
{ display: block;
margin: 0 1px 0 0;
padding: 4px 10px;
width: 60px;
background: #33779C;
color: #FFF;
text-align: center;
text-decoration: none}
#sddm li a:hover
{ background: #49A3FF}
#sddm div
{ position: absolute;
visibility: hidden;
margin: 0;
padding: 0;
background: #EAEBD8;
border: 1px solid #33779C}
#sddm div a
{ position: relative;
display: block;
margin: 0;
padding: 5px 10px;
width: auto;
white-space: nowrap;
text-align: left;
text-decoration: none;
background: #EAEBD8;
color: #2875DE;
font: 11px arial}
#sddm div a:hover
{ background: #49A3FF;
color: #FFF}
And the js:
// Copyright 2006-2007 javascript-array.com
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();
// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';
}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}
// close layer when click-out
document.onclick = mclose;
I’ve been searching the web for a solution in this and I literally tried tens of combinations.
Any help would be appreciated!