Ben Tinner Ben Tinner - 5 months ago 12
CSS Question

hoverable dropdown menu not showing

I am trying to create a hoverable dropdown menu that will work like this.

However, it seems that my website's dropdown menu does not appear.

After inspecting the code (using Developer Tools in Chrome), I found out that my dropdown menu is covered up by my #content div.

What should I do to bring the dropdown menu to the top?



body {
margin: 0;
font-family: "Comic Sans MS", cursive, sans-serif;
background-color: #000000;
background-size: cover;
background-attachment: fixed;
color: #ffffff;
background-image: url("../background/home.jpg")
}

@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

#home {
float: left;
font-size: 1.5em;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(236, 130, 53, 0.75);
position: fixed;
top: 0;
width: 100%;
}

li {
float: right;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

a {
transition: all 0.5s;
}

#content {
margin-top: 61px;
animation: fadein 5s;
}

.menu a {
color: #0000ff;
font-size: 1.5em;
font-weight: bold;
}

.menu a:hover {
background-color: #ff0000;
color: #ffffff;
}

.menu {
display: inline-block
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {
background-color: #f1f1f1
}

.menu:hover .dropdown-content {
display: block;
}

<body>
<div id="navigation-menu">
<ul>
<li class="menu">
<a href="#">Transport</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
</ul>
</div>
<div id="content">
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
</div>
</body>




Answer

Remove overflow: hidden; from the <ul>

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  background-color: rgba(236, 130, 53, 0.75);
  position: fixed;
  top: 0;
  width: 100%;
}

This was stopping the content from flowing outside of the div to give you the effect you are looking for.