Last active
June 5, 2016 07:14
-
-
Save chrisdlangton/405aa7cdf10e0f2b1e9bf59c5f44d517 to your computer and use it in GitHub Desktop.
Drop Down Menu in pure CSS
This file contains 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
*{box-sizing: border-box;} | |
nav{ | |
width: 20%; | |
min-width: 18em; | |
margin: 0 auto; | |
} | |
h1{ | |
position: relative; | |
display: inline-block; | |
font: 2em/1em sans-serif; | |
cursor: pointer; | |
user-select: none; | |
height: 2.1em; | |
} | |
h1:after{ | |
content:""; | |
border: 10px solid transparent; | |
border-top-color: #ccc; | |
position: absolute; | |
right: -30px; | |
top: 15px; | |
} | |
h1:hover + ul{ | |
display: block; | |
} | |
ul{ | |
background: #eee; | |
border: 1px solid #ddd; | |
border-radius: 1%; | |
display: none; | |
position: relative; | |
top: -1.5em; | |
} | |
ul:hover{ | |
display: block; | |
} | |
li{ | |
padding: 3% 5%; | |
border-top: 1px solid #fff; | |
border-bottom: 1px solid #ddd; | |
cursor: pointer; | |
} | |
li:first-child{border-top: none;} | |
li:last-child{border-bottom: none;} | |
li:hover{background: linear-gradient(#eee,#ddd);} |
This file contains 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
<nav> | |
<h1>Drop Down Menu</h1> | |
<ul> | |
<li>Menu Item 1</li> | |
<li>Menu Item 2</li> | |
<li>Menu Item 3</li> | |
</ul> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment