【问题标题】:Laying dropdown menu放置下拉菜单
【发布时间】:2018-06-22 01:41:44
【问题描述】:

我想将我的下拉菜单放在内容上。现在,如果我单击汉堡图标,整个网站都会关闭,但如果我单击汉堡图标,我想修复它。我是使用 z-index 还是其他什么?

看看我的截图:

点击前

点击后

nav {
  width: 100%;
  display: none;
}

ul {
  width: 80%;
  margin: 0 auto;
  padding: 0;
  background-color: #d2141a;
  box-shadow: 1px 1px #000;
  border-top: 4px solid #f4363c;
}

ul,
li {
  display: block;
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid #c1030a;
}

ul,
li:hover {
  background-color: #c1030a;
}

ul,
li,
a {
  text-decoration: none;
  color: #FFF;
  font-weight: 700;
}

.toggle {
  width: 100%;
  padding: 30px 20px;
  text-align: center;
  box-sizing: border-box;
  color: #c72c1b;
  font-size: 25px;
  display: block;
  cursor: pointer;
}

.active {
  display: block;
}
<div class="toggle">
  <i class="fas fa-bars">A</i>
</div>
<nav>
  <ul>
    <li><a href="#">Restaurant</a></li>
    <li><a href="#">Progress</a></li>
    <li><a href="#">Gallery</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>

【问题讨论】:

  • nav{position:absolute}
  • 有效!哦,亲爱的,只有一行:)

标签: html css


【解决方案1】:

您必须添加:

nav{position:absolute}

【讨论】:

    猜你喜欢
    • 2014-08-12
    • 1970-01-01
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 2018-01-27
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多