下拉菜单隐藏在div后面

时间:2014-08-25 09:20:47

标签: jquery html css

有人可以帮我解决这个问题吗?我的下拉菜单一直隐藏在我的div之后。每当我将鼠标悬停在其链接上时,它就在左右div之后。我需要添加jQuery来解决这个问题吗?我无法解决问题。提前谢谢!

#header{
    z-index: 1;
    position: fixed;
    width: 600px;
    margin-top: -20px;
    height: 110px;
    background-color: #98AFC7;
    margin-bottom: 10px;
    text-align:left;
    font-family:Helvetica;

}
p{
text-align:center;
}

#nav{
    position:fixed;
    width:600px;
    margin-top:90px;
    height:60px;
    background-color:#F3E88E;
    margin-bottom:10px;
    font-family:verdana;
    font-size:50;

    }
    body{
    height:600px;
    width:800px;
    margin-left:auto;
    margin-right: auto;
    text-align:left;
    font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, Sans-Serif;
    }


.left {
    position: relative;
    float: left;

    width: 30%;
    height: 450px;
    background-color:#D1D0CE;
    margin-bottom: 0px;
}

.right {
    position: relative;
    float: left;

    width: 70%;
    height: 450px;
    background-color: #C2DFFF;
    margin-bottom: 0px;
    font-family:"Helvetica Neue";
    font-size:14px;


}

#footer {
    position: relative;
    width:600px;
    height: 50px;
    background-color: #98AFC7;
    clear: both;
    font-family: Verdana, sans-serif;
    font-size: 12px;
    text-align: center;
    color: #637c96;
}
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);
#cssmenu {
  font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, Sans-Serif;
  font-size: 10px;
  line-height: 15px;
  text-transform: uppercase;
  text-align: left;
  z-index: 999999;

}
#cssmenu > ul {
  width: auto;
  list-style-type: none;
  padding: 0;
  margin: 0;
  background: #ffffff;
  border: 1px solid #ece6e8;
  border-bottom: 3px solid #d9ced2;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  -o-border-radius: 2px;
  border-radius: 2px;
}
#cssmenu > ul li#responsive-tab {
  display: none;
  /* Hide for large screens */

}
#cssmenu > ul li {
  display: inline-block;
  *display: inline;
  zoom: 1;
}
#cssmenu > ul li.right {
  float: right;
}
#cssmenu > ul li.has-sub {
  position: relative;
}
#cssmenu > ul li.has-sub:hover ul {
  display: block;
}
#cssmenu > ul li.has-sub ul {
  display: none;
  width: 250px;
  position: absolute;
  margin: 0;
  padding: 0;
  list-style-type: none;
  background: #ffffff;
  border: 1px solid #ece6e8;
  border-bottom: 3px solid #d9ced2;
  border-top: 0 none;
}
#cssmenu > ul li.has-sub ul li {
  display: block;
}
#cssmenu > ul li.has-sub > a {
  background-image: url('images/caret.png');
  background-repeat: no-repeat;
  background-position: 90% -95%;
}
#cssmenu > ul li.has-sub > a.active,
#cssmenu > ul li.has-sub > a:hover {
  background: #95B9C7 url('images/caret.png') no-repeat;
  background-position: 90% 195%;
}
#cssmenu > ul li a {
  display: block;
  padding: 12px 24px 11px 24px;
  text-decoration: none;
  color: #747474;
  text-shadow: 0px 1px 0px #fff;
}
#cssmenu > ul li a.active,
#cssmenu > ul li a:hover {
  background: #95B9C7;
  color: #fff;
  text-shadow: 0px 1px 0px #000;
}
@media (max-width: 600px) {
  #cssmenu > ul {
    width: 100%;
  }
  #cssmenu > ul li#responsive-tab {
    display: block;
  }
  #cssmenu > ul li#responsive-tab a {
    background: url('images/menu.png') no-repeat;
    background-position: 95% -35%;
  }
  #cssmenu > ul li#responsive-tab a:hover {
    background-color: #d80041;
    background-position: 95% 135%;
  }
  #cssmenu > ul li {
    display: none;
  }
  #cssmenu > ul li.right {
    float: none;
  }
  #cssmenu > ul li.has-sub {
    position: relative;
  }
  #cssmenu > ul li.has-sub ul {
    display: block;
    position: static;
    width: 100%;
    background: #ffffff;
    border: 0 none;
  }
  #cssmenu > ul li.has-sub ul li {
    display: block !important;
  }
  #cssmenu > ul li.has-sub ul li a span {
    display: block;
    padding-left: 24px;
  }
  #cssmenu > ul li.has-sub > a {
    background-image: none;
  }

}
/* Make sure they show even if hidden in mobile view by JS */
@media (min-width: 600px) {
  #cssmenu > ul > li.collapsed {
    display: inline-block !important;
    *display: inline;
    zoom: 1;
  }
  #cssmenu > ul ul li.collapsed {
    display: block !important;
  }

}

1 个答案:

答案 0 :(得分:0)

z-index仅适用于定位元素(位置:绝对,位置:相对或位置:固定)。 #cssmenu中没有定位元素。所以最好将#header的z-index值更改为-1。 您的新代码

#header{
    z-index: -1;
    position: fixed;
    width: 600px;
    margin-top: -20px;
    height: 110px;
    background-color: #98AFC7;
    margin-bottom: 10px;
    text-align:left;
    font-family:Helvetica;

}