Skip to content

Instantly share code, notes, and snippets.

@lee2sman
Created October 18, 2018 05:51
Show Gist options
  • Save lee2sman/753cbee78909bd498938eada26546bc0 to your computer and use it in GitHub Desktop.
Save lee2sman/753cbee78909bd498938eada26546bc0 to your computer and use it in GitHub Desktop.
Basic (emphasis on the basic) dropdown menu example using HTML and CSS no JS
<!DOCTYPE html>
<!-- for Wyatt / Oct 18 2018 -->
<html>
<head>
<style>
body {
font: 15px arial, sans-serif;
background-color: #ffcccc
}
nav {
display: flex;
justify-content: center;
}
#name {
display: flex;
justify-content: center;
}
.dropbtn {
background-color: red;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: red;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: yellow
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: blue;
}
</style>
</head>
<body>
<div id="name">
<h2>Dropdown Menu</h2>
</div>
<nav>
<div class="dropdown">
<button class="dropbtn">Dropdown 1</button>
<div class="dropdown-content">
<a href="photographs.html">Photographs</a>
<a href="graphicdesign.html">Graphic Design</a>
<a href="somethingelse.html">Something else</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Dropdown 2</button>
<div class="dropdown-content">
<a href="essays.html">Essays</a>
<a href="http://cachemonet.com">Cache Monet</a>
</div>
</div>
</nav>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment