定位下拉菜单的问题

时间:2018-01-28 19:33:23

标签: html css html5 css3 mybb

我想出了一个我从来没有过的问题,那就是z-index。有趣的是,我不能让E10 Info的下拉菜单重叠“容器”和“内容”div。我试过高z-indices但没有成功。任何人都可以帮我解决我做错的事吗? 该网站的网址为 http://forum.economy10.com/ 还有我的一些代码:

<head>
  <style>
    .dropdown {
      position: relative;
      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);
      padding: 12px 16px;
      z-index: 2000000;
      min-height:400px;
    height:400px;
    }

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

        .dropdownd {
      position: relative;
      display: inline-block;
    }

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

    .dropdownd:hover .dropdown-contentd {
      display: block;
    }

  </style>
</head>
<div class="header">
  <div class="longo"></div>
  <a name="top" id="top"></a>
  <div class="wrapper">
    <div class="logo">
      <a href="{$mybb->settings['bburl']}/index.php"><i class="fa fa-bolt" style="color: #fcb941;"></i> {$mybb->settings['homename']}</a>
    </div>
    <!-- If you want to use Image based logo, uncomment this               <div class="logo">
 <a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" title="{$mybb->settings['homename']}" alt="{$mybb->settings['homename']}"></a></div>    
    -->

    <ul id="menu">
      <li><a href="https://economy10.com/"> Home </a></li>
      <li><a href="http://forum.economy10.com/"> Forums </a></li>
      <li>
        <div class="dropdown">
          <a href="#" class="e10i"> E10 Info </a>
          <div class="dropdown-content">
            <ul>
              <li><a href="https://economy10.com/details/"> E10 Overview </a></li>
              <li><a href="https://economy10.com/list-of-suppliers/"> List of Suppliers </a></li>
            </ul>
          </div>
        </div>
      </li>

2 个答案:

答案 0 :(得分:0)

如果你希望你的下拉菜单是透明的,那么在下拉内容div上使用背景颜色属性而不是z-index,只需在下拉列表div上给出alpha(a in rgba或hsla)值0,它将使下拉列表透明。对于前: -     .dropdown-content {background-color:rgba(90,90,90,0);}

答案 1 :(得分:0)

它没有被掩盖它被切断,因为你的标题上有溢出设置隐藏。只需删除它,您就可以看到下拉菜单。

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #FFFFFF;
    color: #DDD;
    z-index: 10000;
    height: 100px;

    //remove the following line
    overflow: hidden;

    -webkit-transition: height 0.3s;
    -moz-transition: height 0.3s;
    transition: height 0.3s;
    text-align: center;
    line-height: 0px;
}