I will be using this one. I want to add sub items to each category(button) how do I do it but maintain the style?

<style>
#message div.menuBar2,
#message div.menuBar2 a.menuButton {
  font-family: Verdana, Arial, sans-serif;
  font-size: 8pt;
  color: #000000;
}

#message div.menuBar2 {
  background-image: url(http://i14.photobucket.com/albums/a345/Instar/escher_background.gif); 

  padding: 6px 2px 6px 2px;
  text-align: center;
  margin-left:20px;
}

#message div.menuBar2 a.menuButton {
  background-color: transparent;
  border: 1px solid;
  border-color: #f0f0f0 #909090 #909090 #f0f0f0;
  color: #000000;
  cursor: pointer;
  left: 0px;
  margin: 1px;
  padding: 2px 6px 2px 6px;
  xposition: relative;
  text-decoration: none;
  top: 0px;
  z-index: 100;
}

#message div.menuBar a.menuButton:hover {
  background-color: transparent;
  border-color: #909090 #f0f0f0 #f0f0f0 #909090;
  color: #000000;
}
</style>




<center><table><tr><td>
<DIV id="message"><div class="menuBar2">
<a class="menuButton" href="">Home</a>

<a class="menuButton" href="{ibf.script_url}act=Search&CODE=getnew">New Posts</a>
<a class="menuButton" href="{ibf.script_url}act=UserCP&CODE=01">Profile</a>
<a class="menuButton" href="{ibf.script_url}act=UserCP&CODE=04">Settings</a>
<a class="menuButton" href="JavaScript:full()">FullScreen</a>
<a class="menuButton" href="http://herproom.5.forumer.com/index.php?act=ST&f=31&t=1873&st=0#entry6049">Link Us</a>
<a class="menuButton" href="http://herproom.5.forumer.com/index.php?act=ST&f=18&t=932">About Us</a>

</div></div>
</td></tr></table></center>

Dani AI

Generated

A concise, practical approach for adding drop-down submenus while keeping the current button look and showing them only on mouseover. The cleanest solution is to use a small wrapper per button, nest a UL for the submenu inside that wrapper (semantic and easy to style), hide the UL by default, and reveal it with CSS :hover. This follows ’s suggestion to use lists and builds on ’s tip to kill bullets with list-style:none.

Example markup and CSS (integrates with existing .menuBar2 / .menuButton concept but keeps submenu rules separate):

<div class="menuBar2">
  <div class="menuItem">
    <a class="menuButton" href="#">Home</a>
    <ul class="subMenu">
      <li><a href="#">Forum A</a></li>
      <li><a href="#">Forum B</a></li>
    </ul>
  </div>
  <div class="menuItem">
    <a class="menuButton" href="#">Profile</a>
  </div>
</div>
.menuItem { display:inline-block; position:relative; margin:1px; }
.menuItem .subMenu { display:none; position:absolute; top:100%; left:0; margin:0; padding:4px 0; list-style:none; z-index:1000; white-space:nowrap; }
.menuItem:hover .subMenu { display:block; }
.subMenu li a { display:block; padding:4px 8px; text-decoration:none; /* reuse visual rules to match .menuButton: border/padding/colors */ }

Troubleshooting tips and caveats: bullets disappear with list-style:none; if the submenu stays visible, confirm the nested UL is inside the .menuItem and that .subMenu default is display:none. position:relative on the parent is required so position:absolute places the submenu directly under the parent. To avoid a hover “gap” while moving the mouse, keep top:100% and make anchor blocks large enough (use display:inline-block or display:block for submenu links). For very old browsers (IE6) that don’t support :hover on non-anchors, add a tiny JS shim that toggles a .hover class on mouseover/mouseout and style .menuItem.hover .subMenu { display:block }. Accessibility can be improved later with keyboard handlers and ARIA roles if needed.

Recommended Answers

All 10 Replies

Thanks But I dont want to use List tag, I want the drop down menu for each menu link shown above in the same style. Only appears on mouseover. no bullets etc

Member Avatar for Member #114696

But why you dont want to use list...it would be better cause it wil be easy to organise it...and yes bullets wont be displayed. And if you dont want to take headache of altering this one, then you see it wont take time. Styles are styles afterall could be reused.

Under each of those menu choices above, I want a dropdown of sub menu items, directly under its parent and only on mouseover, with the same style.

I tried adding <ul> and <li> but sub items appearred below (visible without mouseover) and with ugly black bullets. I want the thing to look neat like the one above.

I will be altering targets of parent items to url of my forums categorys and sub items will be urls of forums within those categorys.

The whole thing should appear as the one above does excepting it will be wider horizontally ofcourse.

see below <ul> <li> example destroys the style

http://www.jmarshall.com/easy/html/testbed.html

<style>
#message div.menuBar2,
#message div.menuBar2 a.menuButton {
  font-family: Verdana, Arial, sans-serif;
  font-size: 8pt;
  color: #000000;
}

#message div.menuBar2 {
  background-image: url(http://i14.photobucket.com/albums/a345/Instar/escher_background.gif); 

  padding: 6px 2px 6px 2px;
  text-align: center;
  margin-left:20px;
}

#message div.menuBar2 a.menuButton {
  background-color: transparent;
  border: 1px solid;
  border-color: #f0f0f0 #909090 #909090 #f0f0f0;
  color: #000000;
  cursor: pointer;
  left: 0px;
  margin: 1px;
  padding: 2px 6px 2px 6px;
  xposition: relative;
  text-decoration: none;
  top: 0px;
  z-index: 100;
}

#message div.menuBar a.menuButton:hover {
  background-color: transparent;
  border-color: #909090 #f0f0f0 #f0f0f0 #909090;
  color: #000000;
}
</style>




<center><table><tr><td>
<DIV id="message"><div class="menuBar2">
<ul id="message"><li>
<a class="menuButton" href="">Home</a><ul>
<li><a href="#">qrayg</a></li>
<li><a href="#">qArcade</a></li>
          <li><a href="#">qLoM</a></li>
          <li><a href="#">qDT</a></li>
        </ul>
      </li>

<a class="menuButton" href="{ibf.script_url}act=Search&CODE=getnew">New Posts</a>
<a class="menuButton" href="{ibf.script_url}act=UserCP&CODE=01">Profile</a>
<a class="menuButton" href="{ibf.script_url}act=UserCP&CODE=04">Settings</a>
<a class="menuButton" href="javascript:full()">FullScreen</a>
<a class="menuButton" href="http://herproom.5.forumer.com/index.php?act=ST&f=31&t=1873&st=0#entry6049">Link Us</a>
<a class="menuButton" href="http://herproom.5.forumer.com/index.php?act=ST&f=18&t=932">About Us</a>

</div></div>
</td></tr></table></center>
Member Avatar for Member #114696

For that you will have to alter a bit of styles. Try it yourself and post what you dont get, afterall practice make a man perfect.

If I asked you to try to design an elaborate building where would you start if you were not an architect?
I understand your intention of encouragement mate, but its like me handing you a screwdriver and saying try to make a rocket!
please just give me an idea/example if how to add style for <ul> <li> tags if thats what you say I need.

I did try to add the same styling for #UL and #LI as for menuBar but it did not work.

.listbuster {list-style: none;}
.....

<ul class="listbuster">
 <li>thing 1</li>
 <li>thing 2</li>
</ul>

gets rid of the bullets.

Thanks that gets rid of bullets but the submenu is still visible. do I put submenu style:none or something?

Member Avatar for Member #114696

Do that using JavaScript.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.