4 Replies Latest reply on Sep 13, 2007 1:34 PM by Newsgroup_User

    center css menu

    Level 7
      I have a horizontal CSS menu with dynamic drop down sub menu's
      In DW design view it is centered, but when previewed in IE it is justified
      left.. I need to center it on the page. Please Help, where am I going wrong.

      Here is the code:

      <script type="text/javascript">
      <!--
      window.onload=subMenu;
      function subMenu(id) {
      var d = document.getElementById(id);
      for (var i = 1; i<=10; i++) {
      if (document.getElementById('smenu'+i))
      {document.getElementById('smenu'+i).style.display='none';}
      }
      if (d) {d.style.display='block';}
      }
      //-->
      </script>


      <style type="text/css">
      body {
      margin: 0;
      padding: 0;
      background: white;
      font: 12px Arial, Helvetica, sans-serif;
      }
      dl, dt, dd, ul, li {
      margin: 0;
      padding: 0;
      list-style-type: none;
      }
      #menu {
      left: auto;
      z-index:100;
      right: auto;
      width: 600px;
      margin-right: auto;
      margin-left: auto;
      }
      #menu dl {
      float: left;
      width: 80px;
      margin: 0 1px;
      }
      #menu dt {
      cursor: pointer;
      text-align: center;
      font-weight: bold;
      background: #ccc;
      border: 1px solid gray;
      }
      #menu dd {
      border: 1px solid gray;
      }
      #menu li {
      text-align: center;
      background: #fff;
      }
      #menu li a, #menu dt a {
      color: #000;
      text-decoration: none;
      display: block;
      height: 100%;
      border: 0 none;
      }
      #menu li a:hover, #menu dt a:hover {
      background: #eee;
      }

      a {text-decoration: none;
      color: black;
      color: #222;
      }
      -->
      </style>
      </head>
      <body>
      <div id="menu">
      <dl>
      <dt onmouseover="javascript:subMenu();"><a href="">Menu</a></dt>
      </dl>
      <dl>
      <dt onmouseover="javascript:subMenu('smenu1');">Menu 1</dt>
      <dd id="smenu1">
      <ul>
      <li><a href="#">Menu 1.1</a></li>
      <li><a href="#">Menu 1.2</a></li>
      <li><a href="#">Menu 1.3</a></li>
      <li><a href="#">Menu 1.4</a></li>
      <li><a href="#">Menu 1.5</a></li>
      <li><a href="#">Menu 1.6</a></li>
      </ul>
      </dd>
      </dl>
      <dl>
      <dt onmouseover="javascript:subMenu('smenu2');">Menu 2</dt>
      <dd id="smenu2">
      <ul>
      <li><a href="#">Menu 2.1</a></li>
      <li><a href="#">Menu 2.2</a></li>
      <li><a href="#">Menu 2.3</a></li>
      <li><a href="#">Menu 2.4</a></li>
      </ul>
      </dd>
      </dl>
      <dl>
      <dt onmouseover="javascript:subMenu('smenu3');">Menu 3</dt>
      <dd id="smenu3">
      <ul>
      <li><a href="#">Menu 3.1</a></li>
      <li><a href="#">Menu 3.2</a></li>
      <li><a href="#">Menu 3.3</a></li>
      <li><a href="#">Menu 3.4</a></li>
      <li><a href="#">Menu 3.5</a></li>
      </ul>
      </dd>
      </dl>
      <dl>
      <dt onmouseover="javascript:subMenu('smenu4');">Menu 4</dt>
      <dd id="smenu4">
      <ul>
      <li><a href="#">Menu 4.1</a></li>
      <li><a href="#">Menu 4.2</a></li>
      <li><a href="#">Menu 4.3</a></li>
      </ul>
      </dd>
      </dl>
      </div>
      </body>

      Jeff