Results 1 to 2 of 2

Thread: Dropdown menu with css and javascript...?

  1. #1
    AllanH Guest

    Exclamation Dropdown menu with css and javascript...?

    Hi, im having trouble with a dropdown menu im trying to get working properly. Im using notepad++ for editing, but not sure thats the problem. My problem is that im not that good at coding, but have to create this menu for a project. Therefor I hope theres someone in here, with the knowledge and time to help me out, so the foldout or expanding of the menu will work. Theres a file with the javascript and one with the css code and i have put them below this.

    File with javascript:

    <!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=iso-8859-1" />
    <title>JavaScript Dropdown Menu</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script type="text/javascript" src="script.js"></script>
    </head>
    <body>
    <ul class="menu" id="menu">
    <li>
    <a href="#" class="menulink">Dropdown Menu 1</a>
    <ul>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 1</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 2</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 3</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 4</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 5</a></li>
    </ul>
    </li>
    <li>
    <a href="#" class="menulink">Dropdown Menu 2</a>
    <ul>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 1</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 2</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 3</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 4</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 5</a></li>
    </ul>
    </li>
    <li>
    <a href="#" class="menulink">Dropdown Menu 3</a>
    <ul>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 1</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 2</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 3</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 4</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 5</a></li>
    </ul>
    </li>
    <li>
    <a href="#" class="menulink">Dropdown Menu 4</a>
    <ul>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 1</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 2</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 3</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 4</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 5</a></li>
    </ul>
    </li>
    <li>
    <a href="#" class="menulink">Dropdown Menu 5</a>
    <ul>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 1</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 2</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 3</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 4</a></li>
    <li><a href="http://www.google.com" class="sub">Dropdown Menu 5</a></li>
    </ul>
    <div id="text" style="float:left; clear:left; width:650px; margin-top:10px">
    </div>
    <script type="text/javascript">
    var menu=new menu.dd("menu");
    menu.init("menu","menuhover");
    </script>
    </body>
    </html>



    -----------

    File with CSS code:

    body {margin:25px; font:11px Verdana,Arial; background:#eee}
    ul.menu {list-style:none; margin:0; padding:0}
    ul.menu * {margin:0; padding:0}
    ul.menu a {display:block; color:#000; text-decoration:none}
    ul.menu li {position:relative; float:left; margin-right:2px}
    ul.menu ul {position:absolute; top:26px; left:0; background:#d1d1d1; display:none; opacity:0; list-style:none}
    ul.menu ul li {position:relative; border:1px solid #aaa; border-top:none; width:148px; margin:0}
    ul.menu ul li a {display:block; padding:3px 7px 5px; background-color:#d1d1d1}
    ul.menu ul li a:hover {background-color:#c5c5c5}
    ul.menu ul ul {left:148px; top:-1px}
    ul.menu .menulink {border:1px solid #aaa; padding:5px 7px 7px; font-weight:bold; background:url(images/header.gif); width:134px}
    ul.menu .menulink:hover, ul.menu .menuhover {background:url(images/header_over.gif)}
    ul.menu .sub {background:#d1d1d1 url(images/arrow.gif) 136px 8px no-repeat}
    ul.menu .topline {border-top:1px solid #aaa}

  2. #2
    mindfullsilence is offline New Member: Posts Will Be Moderated
    Join Date
    May 2009
    Posts
    8

    You're in luck!

    hmm....I actually just did this with the site I'm working on. Mind posting your script.js file?

Similar Threads

  1. JavaScript menu with transparent images (round corners)
    By Mark G in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 02 Sep 2006, 09:21 PM
  2. CSS? (drop-down menu) problem in IE7
    By webbcity in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 17 Feb 2006, 03:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •