+ Reply to Thread
Results 1 to 5 of 5

Thread: Expandable/Collapsable Menu in JS/CSS

  1. #1
    arsonistx is offline x10 Lieutenant arsonistx is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    308

    Cool Expandable/Collapsable Menu in JS/CSS

    I was looking up tutorials on how to do this, and I read quite a few of them and got a basic idea on how to do this.
    So, I decided to make one too. :P
    Here's the tutorial:


    First, if you have a separate stylesheet file, place the code below in there. If you don't, you will have to put it in the <style type="text/css"></style> tags.
    Here is the code:

    Code:
    .plus {
     font-size: 10px;
     font-weight: normal;
     padding: 1px 5px 1px 5px;
     margin: 0px 0px;
     background: #262626; //Replace with any color
     color: #fff; //Replace with any color
     border: 1px solid #fff; //Replace with any color
     cursor: hand;
     cursor: pointer
    }
    
    .plus:hover {
     background: #262626; //Replace with any color
     border: 1px solid #fff; //Replace with any color
    }
    Next, open up the page you want the menu to be on in a text editor. (Notepad )
    Place this code in the <head></head> tag:
    Code:
    <script type="text/javascript">
    
    function toggle(button,area) {
     var tog=document.getElementById(area);
     if(tog.style.display)    {
      tog.style.display="";
     } else {
         tog.style.display="none";
        }
        button.innerHTML=(tog.style.display)?'+':'&minus;';
      }
    </script>
    Now place the following code wherever you want the menu to be:
    Code:
    <h1><span class="plus" onclick="toggle(this,'dis');" title="Click to show/hide">-</span> Navigation</h1>
    <div id="dis" style="" align="center">
    
    place content here
    
    </div>
    Remember, the bold fields MUST match, or the script will not function correctly.


    And there you have it, an expandable/collapsible menu using JavaScript and CSS.

    This exact script is used on my website.
    (Live example: www.arsonistx.whdot.com - right side of the page)

  2. #2
    Emihaumut's Avatar
    Emihaumut is offline x10Hosting Member Emihaumut is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    48

    Re: Expandable/Collapsable Menu in JS/CSS

    I would have totally loved this tutorial had you uploaded it about a month ago when I was trying to install the panels on my website. I spent 3 days messing with the Spry panels, trying to get it to work.

    Regardless though, it seems to be a pretty good tutorial.

    I'll draw pictures for credits :D


  3. #3
    Synkc's Avatar
    Synkc is offline Lord Of The Keys Synkc is an unknown quantity at this point
    Join Date
    Jun 2007
    Location
    Hervey Bay, Australia
    Posts
    1,765

    Re: Expandable/Collapsable Menu in JS/CSS

    Thanks, great tutorial
    E-mail: synkc[at]x10hosting[dot]com
    Hirokima.com

  4. #4
    DarkDragonLord's Avatar
    DarkDragonLord is offline x10 Elder DarkDragonLord is an unknown quantity at this point
    Join Date
    Mar 2007
    Location
    Brazil
    Posts
    782

    Re: Expandable/Collapsable Menu in JS/CSS

    Too bad i cant see the example, your web page is suspended :S
    Regards,
    Raphael DDL

    Designing Solutions for You
    *Web Design;
    *Coding;
    Free Downloads;
    and all related Stuff
    .


    My Tutorials:
    | Multi-Language Websites | Rotative Banners |
    | Bookmark Script for All Browsers
    |
    |
    PHP Switching/Including Content|
    |


  5. #5
    zzurrien's Avatar
    zzurrien is offline x10Hosting Member zzurrien is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    -
    Posts
    45

    Re: Expandable/Collapsable Menu in JS/CSS

    The tutorial is great, but some DarkDragonLord says, the example are suspended
    - zzurrien

+ Reply to Thread

Similar Threads

  1. 300 short cuts of Windows XP
    By goodone in forum Computers & Technology
    Replies: 34
    Last Post: 11-29-2011, 12:12 AM
  2. Create Right Click Menu in Flash
    By satheesh in forum Tutorials
    Replies: 2
    Last Post: 10-04-2007, 06:42 AM
  3. Joomla - Problem with URL links in Menu
    By Axe_Swipe in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 08-29-2007, 08:44 PM
  4. No funcionan los enlaces de mi menu
    By Rey_Lich in forum Soporte
    Replies: 6
    Last Post: 07-09-2007, 03:38 PM
  5. How do you make Scrolling Menu Bars and Jump Bars
    By Album in forum Free Hosting
    Replies: 3
    Last Post: 10-16-2005, 11:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers