Skip to content

Instantly share code, notes, and snippets.

@barraponto
Created April 12, 2012 16:33
Show Gist options
  • Select an option

  • Save barraponto/2368909 to your computer and use it in GitHub Desktop.

Select an option

Save barraponto/2368909 to your computer and use it in GitHub Desktop.
pure css accordion
/**
* pure css accordion
*/
body { width: 240px; }
ul { padding: 0; margin: 0; }
h2 { margin-top: 0; margin-bottom: 0.25em; }
h2 a { text-decoration: none; color: #905; }
li p { transition: height 1.5s; height: 0; overflow: hidden; margin: 0; }
li:target p { height: 81px; }
/* unfortunatelly, I can't use height: auto;
/* because it is not supported by css transitions yet.
/* see http://oli.jp/2010/css-animatable-properties/ */
<!-- content to be placed inside <body>…</body> -->
<ul>
<li id="a"><h2><a href="#a">click me!</a></h2><p>this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text.</p></li>
<li id="b"><h2><a href="#b">no, click me!</a></h2><p>this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text.</p></li>
<li id="c"><h2><a href="#c">click me, i tell you!</a></h2><p>this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text. this is filler text.</p></li>
</ul>
{"view":"separate","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment