Designs Advice » General Talk

cascading menu with premade background images

Tags:

3 posts repliesLatest post: 2 years by drew

  • This topic is not a help request
    1. rockstar
      No uploaded avatar
      Member

      alright so now im trying to make a cascading(dropdown) menu for my customers page
      i basically want to take the pre-existing menu bar and add drop down menu effects to the products and designs portions

      i have several images already made, now i need the code to make them functional

      rockstar.we.bs/images/menu_02.gif
      rockstar.we.bs/images/2menu_02.gif
      rockstar.we.bs/images/2menu_03.gif
      rockstar.we.bs/images/hilite1.gif
      rockstar.we.bs/images/hilite2.gif
      rockstar.we.bs/images/hilite3.gif
      rockstar.we.bs/images/hilite4.gif

      all the code i have found so far has been for plain menus
      and doesnt refer to how to add images for backgrounds

      any help would be appreciated,
      thanks

      Posted 2 years ago # Link
    2. rockstar
      No uploaded avatar
      Member

      sorry the customers page is here

      Posted 2 years ago # Link
    3. drew

      Member

      maybe something like this will help

      <ul id="nav">
        <li>Heading
          <ul>
            <li><a href="">Menu1»
              drop</a></li>
            <li><a href="">Option1</a></li>
            <li><a href="">Option2</a></li>
            <li><a href="">option3</a></li>
      		</ul>
      	</li>
      
        <li>Grunts
          <ul>
            <li><a href="">Menu2
              </a></li>
            <li><a href="">Option1</a></li>
            <li><a href="">Option2</a></li>
          </ul>
        </li>
      
        <li>menu3
          <ul>
            <li><a href="">Option1</a></li>
            <li><a href="">Option2</a></li>
            <li><a href="">option3</a></li>
          </ul>
        </li>
      </ul>

      Styling it

      To get started, all of the lists need to be jigged around a bit — namely, the padding and margin set to zero and the list-style set to none:

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

      Now we need to transform the first-level list into a horizontal menu bar. There are a number of methods to do this, discussed in detail elsewhere. We could display the list-items inline (display: inline), but for this example, we are going to float them to the left.

      li {
        float: left;
        position: relative;
        width: 10em;
        }

      The position has been set to relative because we want the position of the second-level, nested lists to be relative to the first-level list items and the width has been set to space it out a bit. The dropdown menu is coming together.

      The next step is to tackle the second-level lists that will be the dropdowns themselves:

      li ul {
        display: none;
        position: absolute;
        top: 1em;
        left: 0;
        }

      This positions the second-level lists absolutely (pulling them out of the flow of HTML into a world all of their own) and sets their initial state to not be displayed. If you substitute display: none with display: block, you will see the need for the top and left properties in Internet Explorer, because without them, IE will align the second-level lists to the top right of their relative parent rather than the bottom left. Unfortunately, this IE fix will mess things up in browsers like Opera, so add the following CSS to reset the top and left properties on all but IE browsers:

      li > ul {
      	top: auto;
      	left: auto;
      	}

      And now, making the sucker work. To make a second-level list appear when its parent list item is “rolled over,” we simply need to add the following:

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

      Which says that any list that is nested in a list item that has the cursor hovering over it should be displayed.

      Finally, because the lists are floated left, the content underneath it needs to be set free of the floating by applying clear: left to it.

      Now add this JavaScript

      <script type="text/javascript"><!--
      startList = function() {
      if (document.all&&document.getElementById) {
      navRoot = document.getElementById("nav");
      for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
      node.onmouseover=function() {
      this.className+=" over";
        }
        node.onmouseout=function() {
        this.className=this.className.replace(" over", "");
         }
         }
        }
       }
      }
      window.onload=startList;
      -></script>

      Heres an example: http://www.htmldog.com/articles/suckerfish/bones/

      Posted 2 years ago # Link

    RSS feed for this topic

    Reply

    You must log in to post.