I'm just learning HTML and CSS and I've started making my first layout template.
I've come across a problem when I've tried to use a drop down menu on my layout.
The menu drops down, but part of it is hidden behind the div that is below the menu bar.
I've tried adding a z-index to anything related to the menu, however I'm not too sure where to put it to get it to work properly.
If I remove the background-color from the #main div, you can see the rest of the drop down, but you can't actually click on the links because the drop down disappears again if you move the mouse outside of the div.
Here's the code I'm working with:
#menu {
float: left;
background-color: #eeeeee;
width:1000px;
border: 1px solid black;
height: 50px;
}
#main {
float: left;
width: 990px;
height: 50px;
background-color: white;
border: 1px solid black;
padding-left: 10px;
}
/* Just making the links look a bit like buttons */
#menu ul {
margin-left: -2.5em;
}
#menu li ul {
display: none;
}
#menu li:hover ul {
display: block;
}
#menu li {
list-style-type: none;
width: 8em;
text-align: center;
float: left;
margin-right: 1em;
}
#menu a {
color: black;
text-decoration: none;
display: block;
box-shadow: 5px 5px 5px grey;
background-color: #CCCCCC;
border: 1px outset grey;
border-radius: 5px;
}
#menu a:hover {
background-color: #DDDDDD;
border: none;
box-shadow: 2px 2px 2px grey;
}
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet"
type="text/css"
href="test.css">
</head>
<body>
<div id="menu">
<ul>
<li><a>Link1</a></li>
<li><a>Link1</a></li>
<li><a>Link3</a>
<ul>
<li><a>SubLink1</a></li>
<li><a>SubLink2</a></li>
</ul>
</li>
<li><a>Link4</a></li>
</ul>
</p>
</div>
<div id="main">
<p>
Lorem ipsum dolor sit amet, similique assueverit id pro. Agam insolens
deterruisset ei usu. In eos vocent numquam, an exerci tamquam complectitur
his.
</p>
</div>
</body>
</html>
How do I get the menu to drop down over the below div?? HELP!