jQueryとCSS3で作るアコーディオンメニュー

HTML

<ul id="accordion">
  <li><a href="#">カテゴリー1</a>
    <ul id="active">
      <li><a href="1.html">サブカテゴリー1</a></li>
      <li><a href="2.html">サブカテゴリー2</a></li>
      <li><a href="3.html">サブカテゴリー3</a></li>
    </ul>
  </li>
  <li><a href="#">カテゴリー2</a>
    <ul>
      <li><a href="1.html">サブカテゴリー1</a></li>
      <li><a href="2.html">サブカテゴリー2</a></li>
      <li><a href="3.html">サブカテゴリー3</a></li>
    </ul>
  </li>
  <li><a href="#">カテゴリー3</a>
    <ul>
      <li><a href="1.html">サブカテゴリー1</a></li>
      <li><a href="2.html">サブカテゴリー2</a></li>
      <li><a href="3.html">サブカテゴリー3</a></li>
    </ul>
  </li>
  <li><a href="#">カテゴリー4</a>
    <ul>
      <li><a href="1.html">サブカテゴリー1</a></li>
      <li><a href="2.html">サブカテゴリー2</a></li>
      <li><a href="3.html">サブカテゴリー3</a></li>
    </ul>
  </li>
  <li><a href="#">カテゴリー5</a>
    <ul>
      <li><a href="1.html">サブカテゴリー1</a></li>
      <li><a href="2.html">サブカテゴリー2</a></li>
      <li><a href="3.html">サブカテゴリー3</a></li>
    </ul>
  </li>
</ul>

CSS

@font-face {
	font-family: 'Typicons';
	src: url('fonts/typicons-regular-webfont.eot');
	src: url('fonts/typicons-regular-webfont.eot?#iefix') format('embedded-opentype'),
		url('fonts/typicons-regular-webfont.woff') format('woff'),
		url('fonts/typicons-regular-webfont.ttf') format('truetype'),
		url('fonts/typicons-regular-webfont.svg#TypiconsRegular') format('svg');
	font-weight: normal;
	font-style: normal;
}
#accordion{
  list-style: none;
  width: 500px;
  font-size: 16px;
  line-height: 1;
  background-color: #add8e6;
  background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, .2) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%,transparent 75%, transparent);
  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .2) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%,transparent 75%, transparent);
  background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .2) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%,transparent 75%, transparent);
  background-image: -ms-linear-gradient(45deg, rgba(255, 255, 255, .2) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%,transparent 75%, transparent);
  background-image: linear-gradient(45deg, rgba(255, 255, 255, .2) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%,transparent 75%, transparent);
  -moz-background-size: 4px 4px;
  -webkit-background-size: 4px 4px;
  -o-background-size: 4px 4px;
  -ms-background-size: 4px 4px;
  background-size: 4px 4px;
  margin: 0;
  padding: 0;
  border-top: 15px solid #1b4958;
  border-bottom: 15px solid #1b4958;
  border-radius: 3px;
  box-shadow: 2px 3px 2px rgba(0,0,0,.2);
}
#accordion > li{
  padding: 0;
  border-right: 1px solid #3a9fc0;
  border-left: 1px solid #3a9fc0;
}
#accordion li a{
  display: block;
  position:relative;
  color: #333;
  text-decoration:none;
  text-shadow: 0 1px 1px rgba(255,255,255,.7);
  padding: 15px 45px;
  border-bottom: 1px solid #79bfd6;
  border-top: 1px solid #eef7fa;
  -moz-transition: .3s;
  -webkit-transition: .3s;
  -o-transition: .3s;
  -ms-transition: .3s;
  transition: .3s;
}
#accordion > li:first-child > a{
  border-top: 0px;
}
#accordion > li a:before {
  position: absolute;
  top: 50%;
  left: 15px;
  font: 24px/100% 'Typicons';
  content: "\0023";
  color: #2f7f99;
  margin-top: -10px;
  text-shadow: 1px 1px 0px rgba(255,255,255,.7);
}
#accordion li a:hover{
  color: #1b4958;
  background: rgba(0,0,0,.1);
  border-top-color: #c7e4ee;
}
.arrow{
  position:absolute;
  top:50%;
  right: 30px;
  width: 30px;
  height: 20px;
  line-height: 1;
  text-shadow: 0 -1px 0px rgba(0,0,0,.3);
  margin-top: -10px;
  color: #d4ebf2;
  -moz-transition: .3s;
  -webkit-transition: .3s;
  -o-transition: .3s;
  -ms-transition: .3s;
  transition: .3s;
}
.arrow:before{
  font: 30px 'Typicons';
  content: "7";
}
#accordion li > a:hover .arrow{
  color: #2f7f99;
}
.rotate {
  color:#2f7f99;
  -moz-transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
}
#accordion li ul {
  list-style: none;
  background: #e1f1f6;
  margin: 0;
}
#accordion li ul li a{
  position:relative;
  background: none;
  line-height: 1;
  padding: 15px 70px;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #a0d2e2;
}
#accordion li ul li a:before {
  position: absolute;
  top: 50%;
  left:45px;
  content: "x";
  font:16px/100% 'Typicons';
  color: #2f7f99;
  margin-top: -8px;
  text-shadow: 1px 1px 0 rgba(0,0,0,.5);
  -moz-transition: .3s;
  -webkit-transition: .3s;
  -o-transition: .3s;
  -ms-transition: .3s;
  transition: .3s;
}
#accordion li ul li:first-child a{
  border-top: 0px;
  box-shadow: 0 7px 7px -7px rgba(0,0,0,.5) inset;
}
#accordion li ul li:last-child a{
  border-bottom: 1px solid #5fb3ce;
}
#accordion li ul li a:hover{
  background: #d4ebf2;
  border-top-color: #eef7fa;
}

jQuery

$(function() {
   $("#accordion li ul").hide();
   $("#active").show();
   $("#accordion > li > a").click(function(){
       var click = $("+ul",this);
	   click.slideDown();
       $("#accordion ul").not(click).slideUp();
	   $(".arrow").removeClass("rotate");
	   $("> .arrow",this).addClass("rotate");
       return false;
   });
});