Created
April 29, 2013 08:49
-
-
Save ramsesoriginal/5480457 to your computer and use it in GitHub Desktop.
Collapsing menu using flexbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Collapsing menu using flexbox | |
*/ | |
ul { | |
list-style: none; | |
display: block; | |
position: relative; | |
padding: 0; | |
margin: 0; | |
display: -webkit-flex; | |
display: flex; | |
-webkit-flex-flow: column; | |
flex-flow: column; | |
} | |
li { | |
transition: .75s; | |
background-color: red; | |
display: block; | |
position: relative; | |
overflow: hidden; | |
margin: 0; | |
transform-origin: 0 0; | |
-webkit-flex: 0 1 auto; | |
flex: 0 1 auto; | |
height: 0; | |
padding: 0 1em; | |
} | |
li a { | |
display: block;} | |
li.current { | |
z-index: 2; | |
background-color: green; | |
-webkit-flex: 10 1 auto; | |
flex: 10 1 auto; | |
} | |
li.current, | |
ul:hover li { | |
height: 1.5em; | |
padding: 1em; | |
} | |
ul:hover li.current { | |
-webkit-flex: 0 1 auto; | |
flex: 0 1 auto; | |
} | |
ul:hover li:hover { | |
background-color: pink; | |
-webkit-flex: 2 1 auto; | |
flex: 2 1 auto; | |
padding-top: 3em; | |
padding-bottom: 3em; | |
} | |
li:hover a{ | |
color: white; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- content to be placed inside <body>…</body> --> | |
<ul> | |
<li><a href="#">1</a></li> | |
<li class="current"><a href="#">2</a></li> | |
<li><a href="#">3</a></li> | |
<li><a href="#">4</a></li> | |
<li><a href="#">5</a></li> | |
<ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hello world!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment