Cascading Style Sheets Tutorial

CSS effect hide / show-type menu

<head>
<script>
  If (! Document.getElementById) 
  Document.getElementById = function () (return null;) 

  Function initializeMenu (menuId, actuatorId) ( 
  Var menu = document.getElementById (menuId); 
  Var actuator = document.getElementById (actuatorId); 

  If (menu == null | | actuator == null) return; 

  / / If (window.opera) return; / / I'm too tired 

  Actuator.parentNode.style.backgroundImage = "url (/ images / plus.gif)"; 
  Actuator.onclick = function () ( 
  Var display = menu.style.display; 
  This.parentNode.style.backgroundImage = 
  (Display == "block")? "Url (/ images / plus.gif)": "url (/ images / minus.gif)"; 
  Menu.style.display = (display == "block")? "None": "block"; 

  Return false; 
  ) 
  ) 
  Window.onload = function () ( 
  InitializeMenu ( "productsMenu", "productsActuator"); 
  InitializeMenu ( "newPhonesMenu", "newPhonesActuator"); 
  InitializeMenu ( "compareMenu", "compareActuator"); 
  ) 
  </ Script> 
<style>
  Body ( 
  Font-family: verdana, helvetica, arial, sans-serif; 
  ) 

  (# MainMenu 
  Background-color: # EEE; 
  Border: 1px solid # CCC; 
  Color: # 000; 
  Width: 203px; 
  ) 

  (# MenuList 
  Margin: 0px; 
  Padding: 10px 0px 10px 15px; 
  ) 

  Li.menubar ( 
  Background: url (/ images / plus.gif) no-repeat 0em 0.3em; 
  Font-size: 12px; 
  Line-height: 1.5em; 
  List-style: none outside; 
  ) 

  . Menu,. Submenu ( 
  Display: none; 
  Margin-left: 15px; 
  Padding: 0px; 
  ) 

  . Menu li,. Submenu li ( 
  Background: url (/ images / square.gif) no-repeat 0em 0.3em; 
  List-style: none outside; 
  ) 

  A.actuator ( 
  Background-color: transparent; 
  Color: # 000; 
  Font-size: 12px; 
  Padding-left: 15px; 
  Text-decoration: none; 
  ) 

  A.actuator: hover ( 
  Text-decoration: underline; 
  ) 

  . Menu li a,. Submenu li a ( 
  Background-color: transparent; 
  Color: # 000; 
  Font-size: 12px; 
  Padding-left: 15px; 
  Text-decoration: none; 
  ) 

  . Menu li a: hover, submenu li a: hover ( 
  / * Border-bottom: 1px dashed # 000 * / 
  Text-decoration: underline; 
  ) 

  Span.key ( 
  Text-decoration: underline; 
  ) 
  </ Style> 
  </ Head> 
<body>
  <div Id="mainMenu"> 
  <ul Id="menuList"> 
  <li Class="menubar"> 
  <a Href="#" id="productsActuator" class="actuator"> Phones </ a> 
  <ul Id="productsMenu" class="menu"> 
<li>
  <a Href="#" id="newPhonesActuator" class="actuator"> New Phones </ a> 
  <ul Id="newPhonesMenu" class="submenu"> 
  <li> <a Href="#"> 9290 </ a> </ li> 
  <li> <a Href="#"> 8390 </ a> </ li> 
  <li> <a Href="#"> 8290 </ a> </ li> 
  <li> <a Href="#"> 8270 </ a> </ li> 
  </ Ul> 
  </ Li> 
<li>
  <a Href="#" id="compareActuator" class="actuator"> Compare </ a> 
  <ul Id="compareMenu" class="submenu"> 
  <li> <a Href="#"> All Phones </ a> </ li> 
  <li> <a Href="#"> Service Provider </ a> </ li> 
  </ Ul> 
  </ Li> 
  </ Ul> 
  </ Li> 
  </ Ul> 
  </ Div> 
  </ Body> 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • DZone

Tags: css drop-down menu, CSS effect, css menu, List Style Type

Releated Posts

  • CSS technology and image dynamic effect of menu navigation
  • Css javascript + + dhtml classic practical effect of strong points - Tree menu, tab, sort forms are available from here!
  • Flash XML wrote a menu similar to the effect of Korea
  • Flash Mac produced the effect of the menu system
  • CSS menu examples: the effect of red-hot concise Besieged City

This entry was posted on Thursday, January 31st, 2008 at 12:00 am and is filed under CSS Tutorial By Examples. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

« How to use their own CSS Blog replace the default style (Author: Xuefeng)
Site Reconstruction CSS style sheet and the optimization techniques »

Leave a Reply

  • Categories

    • CSS Properties (491)
    • CSS Tutorial (1154)
    • CSS Tutorial By Examples (1201)
    • Css+Div Web Design (3274)
    • Xhtml and Web Design (1797)
  • Archives

    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
  • Pages

    • About us

Cascading Style Sheets Tutorial