CSS3だけでアコーディオンメニューをつくる|デモ

Products

ここにはメニューの説明文とかを入れておけばいいでしょうね。デモの為にちょっと長めにテキストを書いてみます。

Highlight

ここにはメニューの説明文とかを入れておけばいいでしょうね。デモの為にちょっと長めにテキストを書いてみます。

News

ここにはメニューの説明文とかを入れておけばいいでしょうね。デモの為にちょっと長めにテキストを書いてみます。

Contact Us

ここにはメニューの説明文とかを入れておけばいいでしょうね。デモの為にちょっと長めにテキストを書いてみます。

ソースコード

CSS

#accordion .item {
    width: 400px;
    height: 30px; /* height = total height of A child element */
    overflow: hidden;
    
    transition: height ease-in-out 500ms; /* css3 transition */
    -o-transition: height ease-in-out 500ms;
    -moz-transition: height ease-in-out 500ms;
    -webkit-transition: height ease-in-out 500ms;
    
    border: 1px solid #ccc;
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    
    margin-bottom: 2px;
}
#accordion a {
	display: block;
	height: 20px;
	line-height: 20px;
	background: #6CF;
	padding: 5px;
	color: #1e1e1e;
	text-decoration: none;
}
#accordion p {
    height: 150px;
    padding: 5px;
	text-align: left;
}
#accordion div:hover {
    height: 180px; /* height = total height of A and P child elements */
}
#accordion div:hover a {
    border-bottom: 1px solid #ccc;
    font-weight: bold;
}

このコードが動くのは、Safari・chromeのwebkit系です。いまのところFirefoxでは動作しません。
kruz-graphix.com