Jump to content

Recommended Posts

Im trying to align my drop down menu, so that is aligned (a bit to the left) closer to the text in my navigation bar.

 

www.1pw.co.uk/navigation.html

 

Im not sure wether or not this aligned the way it is because of my css?

If it is can anyone explain what part of the code is responsible for the horizontal alignment?

 

 

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.centre {margin-left:auto; margin-right:auto; width:980px; background-color:#009900;}

.dropdown {
    float: left; /* important */
font-family:Tahoma, Geneva, sans-serif;
    margin-bottom: auto;  
    margin-top: auto;
background-color:#009900;

}
.dropdown dt {
    background-color: #009900;
    color: #FFFFFF;
    cursor: pointer;
    font-weight: bold;
    margin-left: 5px;
width:120px;
}
.dropdown dt:hover {
    background-color: #009900;
    color: #FFF;
}
.dropdown dd {
    background-color: #009900;
    display: none;
    opacity: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    position: absolute;
    width: 220px;
}
.dropdown ul {
    border-top-color: -moz-use-text-color;
    border-top-style: none;
    border-top-width: medium;
    list-style-position: outside;
    width: 150px;
}
.dropdown li {
    display: inline;
}
.dropdown a, .dropdown a:active, .dropdown a:visited {
    -moz-text-blink: none;
    -moz-text-decoration-color: -moz-use-text-color;
    -moz-text-decoration-line: none;
    -moz-text-decoration-style: solid;
    background-color: #009900;
    color: #FFFFFF;
    display: block;
    width: 150px;
}
.dropdown a:hover {
    background-color: #FF9933;
    color: #000000;
}
.dropdown .underline {
    border-bottom-color: #B9D6DC;
    border-bottom-style: solid;
    border-bottom-width: 1px;
text-decoration:none;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}

</style>

<script type="text/javascript">
var DDSPEED = 2;
var DDTIMER = 2;
// main function to handle the mouse events //
function ddMenu(id,d){
var h = document.getElementById(id + '-ddheader');
var c = document.getElementById(id + '-ddcontent');
clearInterval(c.timer);
if(d == 1){
clearTimeout(h.timer);
if(c.maxh && c.maxh <= c.offsetHeight){return}
else if(!c.maxh){
c.style.display = 'block';
c.style.height = 'auto';
c.maxh = c.offsetHeight;
c.style.height = '0px';
}
c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
}else{
h.timer = setTimeout(function(){ddCollapse(c)},50);
}
}
// collapse the menu //
function ddCollapse(c){
c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}
// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
var h = document.getElementById(id + '-ddheader');
var c = document.getElementById(id + '-ddcontent');
clearTimeout(h.timer);
clearInterval(c.timer);
if(c.offsetHeight < c.maxh){
c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
}
}
// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
var currh = c.offsetHeight;
var dist;
if(d == 1){
dist = (Math.round((c.maxh - currh) / DDSPEED));
}else{
dist = (Math.round(currh / DDSPEED));
}
if(dist <= 1 && d == 1){
dist = 1;
}
c.style.height = currh + (dist * d) + 'px';
c.style.opacity = currh / c.maxh;
c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
clearInterval(c.timer);
}
}
</script>
</head>
<body>

<div class="centre">
<dl class="dropdown" style="width:100px;">

  <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)">Home</dt>
  <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)">
  
  </dd>
</dl>

<dl class="dropdown">
  <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)">Grounds<br/>Maintenance</dt>
  <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)">
    <ul>
      <li><a href="#" class="underline">Commercial Services</a></li>
      <li><a href="#" class="underline">Lawn Treatment</a></li>
      <li><a href="#" class="underline">Hedge Trimming</a></li>
      <li><a href="#" class="underline">Weed Control</a></li>
      <li><a href="#" class="underline">Ivy Control</a></li>
      <li><a href="#" class="underline">One Off Tidy Up's</a></li>
      <li><a href="#" class="underline">Litter Picking</a></li>
    </ul>
  </dd>
</dl>

<dl class="dropdown">
  <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)">Cleaning<br/>Services</dt>
  <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)">
    <ul>
      <li><a href="#" class="underline">Contract Cleaning</a></li>
      <li><a href="#" class="underline">Deep Kitchen Clean</a></li>
      <li><a href="#" class="underline">Outside Jetwashing</a></li>
      <li><a href="#" class="underline">Graffiti Removal</a></li>
      <li><a href="#" class="underline">One Off Cleans</a></li>     
    </ul>
  </dd>
</dl>

<dl class="dropdown">
  <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)">Property<br/>Services</dt>
  <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)">
    <ul>
      <li><a href="#" class="underline">Painting & Decorating</a></li>
      <li><a href="#" class="underline">Handyman Service</a></li>     
    </ul>
  </dd>
</dl>
   
    <dl class="dropdown">
  <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)">Knotweed<br/>Control</dt>
  <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)">
    <ul>
      <li><a href="#" class="underline">What is Knotweed?</a></li>
      <li><a href="#" class="underline">Knotweed Treatment</a></li>     
    </ul>
  </dd>
</dl>
  
    <dl class="dropdown">
  <dt id="six-ddheader" onmouseover="ddMenu('six',1)" onmouseout="ddMenu('six',-1)">Landscaping</dt>
  <dd id="six-ddcontent" onmouseover="cancelHide('six')" onmouseout="ddMenu('six',-1)">
    <ul>
      <li><a href="#" class="underline">Turfing</a></li>
      <li><a href="#" class="underline">Planting</a></li>
      <li><a href="#" class="underline">Fencing</a></li>        
    </ul>
  </dd>
</dl>
      
    <dl class="dropdown">
  <dt id="seven-ddheader" onmouseover="ddMenu('seven',1)" onmouseout="ddMenu('seven',-1)">Rubbish<br/>Collection</dt>
  <dd id="seven-ddcontent" onmouseover="cancelHide('seven')" onmouseout="ddMenu('seven',-1)">
    <ul>
      <li><a href="sitemanagement.html" class="underline">Clearance Services</a></li>    
    </ul>
  </dd>
</dl>   
    
    <dl class="dropdown">
  <dt id="eight-ddheader" onmouseover="ddMenu('eight',1)" onmouseout="ddMenu('eight',-1)">Contact</dt>
  <dd id="eight-ddcontent" onmouseover="cancelHide('eight')" onmouseout="ddMenu('eight',-1)">
    <ul>
      <li><a href="#" class="underline">Contact</a></li>
      <li><a href="#" class="underline">Facebook</a></li>
      <li><a href="#" class="underline">Google+</a></li>       
    </ul>
  </dd>
</dl>

<div style="clear:both" /></div>
</div><!--centre-->

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/257167-css-in-my-drop-down-menu/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.