Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Sign in with OpenID
Sign In
Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

CSS Menus

/skill level/
/viewed/
0 Times

The code here creates a drop-down menu from HTML list elements using CSS. The code was written for and referenced to in Webmonkey's Add CSS Drop-Down Menus tutorial.

This code is in a wiki. If you have any advances to make to the original tutorial and code, please feel free to contribute.

The Code

<html>
<head>


<style type="text/css">
ul {
	margin: 0;
	padding: 0;
	list-style: none;
}
ul li {
	position: relative;
	float: left;
	width: 100px;
}
li ul {
	position: absolute;
	top: 30px;
	opacity: 0;
	
}
ul li a {
	display: block;
	text-decoration: none;
	line-height: 20px;
	color: #777;
	padding: 5px;
	background: #CC0;
	margin: 0 2px;
	display: block; 
    -webkit-transition-property: background-color, color, text-shadow;
    -webkit-transition-duration: .5s;
    -webkit-transition-timing-function: ease-in;
}
ul li a:hover { background: #66F; }
li:hover ul { opacity: 1;
-webkit-transition: opacity 4s linear;
  
}
</style>

<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>


</head>
<body>
<ul>
	<li><a href="">Home</a></li> 
    <li><a href="">Web</a> 
      <ul> 
        <li><a href="#">Browser</a></li> 
        <li><a href="#">Search</a></li> 
      </ul> 
    </li> 
    <li><a href="">Monkey</a> 
      <ul> 
        <li><a href="">Eating Banana</a></li> 
        <li><a href="">Throwing Poop</a></li> 
      </ul> 
    </li>
    <li><a href="">Contact</a> 
      <ul> 
        <li><a href="">Via Web</a></li> 
        <li><a href="">Via Phone</a></li> 
        <li><a href="">Via tin can and string</a></li> 
      </ul> 
    </li> 
</ul>
</body>
</html>

What it Looks Like

Edit this article
Reddit Digg
 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year