Krispy Krispy - 2 months ago 19
HTML Question

CSS Drop-Up Menu Questions

I want to create a drop-up menu for a website, but my menu items are only showing up on the right but i want them to show up above the option. How do I fix this?

Also would appreciate some help figuring out how to correct the code to let me hover over the available drop-up menu options.

Here is the link to the website if anyone wants to check it out to see what the code looks like.

http://www.public.asu.edu/~kwenzel3/IFT301FallAKrisW/Final.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Milestone</title>
<style type="text/css">

body {
background-color: gray;
background-image: url('images/backgroundpic.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}

ul {
list-style-type: none;
position: fixed;
bottom: 0;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

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

li a:hover, .dropdown:hover .dropbtn {
background-color: #87cefa;
}

li.dropdown {
display: inline-block;
}

.dropdown-content {
display: none;
position: fixed;
bottom: 0;
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}

.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>

<ul>
<li class="dropdown">
<a href="#" class="dropbtn">Home</a>
<div class="dropdown-content">
<a href="#">Home Page</a>
</div>

<li class="dropdown">
<a href="#" class="dropbtn">Music</a>
<div class="dropdown-content">
<a href="#">Song 1</a>
<a href="#">Song 2</a>
<a href="#">Song 3</a>
</div>

<li class="dropdown">
<a href="#" class="dropbtn">Videos</a>
<div class="dropdown-content">
<a href="#">Video 1</a>
<a href="#">Video 2</a>
<a href="#">Video 3</a>
</div>

<li class="dropdown">
<a href="#" class="dropbtn">Tour</a>
<div class="dropdown-content">
<a href="#">North America Dates</a>
<a href="#">Europe Dates</a>
<a href="#">Misc Dates</a>
</div>

<li class="dropdown">
<a href="#" class="dropbtn">Contact</a>
<div class="dropdown-content">
<a href="#">Comments</a>
<a href="#">Technical Support</a>
<a href="#">Booking</a>
</div>
</li>
</ul>

</body>
</html>

Answer

Change position: fixed to position: absolute and set left and bottom positions for .dropdown-content and set the li to position: relative;

ul li {
  position: relative;
}

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

and remove overflow: hidden from ul as well...