我一直在玩這個滑動下拉式jquery菜單。我將下拉區域上移一點,並帶有負邊界。我希望有一種方法可以在父元素上層疊下拉菜單,這是操作的觸發器。我試過z-index但沒有運氣。任何人都知道我在做什麼錯了?使用css分層疊加元素
這活:爲http://daveywhitney.com/overlay/sliding_menu.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>Sliding Menu Tutorial | HV-DESIGNS.CO.UK</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="button">
<div id="trigger">
<img src="images/button.png" width="184" height="32" class="menu_class" />
</div>
<ul class="the_menu">
<li><a href="#">A Website #1</a></li>
<li><a href="#">A Website #2</a></li>
<li><a href="#">A Link #1</a></li>
<li><a href="#">A Link #2</a></li>
<li><a href="#">A Website #3</a></li>
<li><a href="#">A Website #4</a></li>
<li><a href="#">A Link #3</a></li>
<li><a href="#">A Link #4</a></li>
</ul>
</div>
</div>
</body>
</html>
body {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
background-color: #333333;
}
#container {
margin: auto;
width: 490px;
}
#header {
background-image: url(images/header.png);
background-repeat: no-repeat;
height: 42px;
width: 490px;
margin-bottom: 20px;
}
#button {
height: 32px;
width: 184px;
margin: auto;
}
ul, li {
margin:0;
padding:0;
list-style:none;
}
.menu_class {
border:1px solid #1c1c1c;
}
#trigger {
z-index:-1;
}
.the_menu {
display:none;
width:300px;
border: 1px solid #1c1c1c;
margin:-50px 0 0 50px;
z-index:100;
}
.the_menu li {
background-color: #302f2f;
}
.the_menu li a {
color:#FFFFFF;
text-decoration:none;
padding:10px;
display:block;
}
.the_menu li a:hover {
padding:10px;
font-weight:bold;
color: #F00880;
}