Why does the paragraph always cover the div that is shown when you hover over link 1 in this example? I have tried changing the z-index of both the paragraph and the list, but nothing works. The thing that really makes me not understand is the fact that during the transition, the list appears over the paragraph. Then, after the transition, the paragraph seems to change z-index. Any help would be great.

为什么段落总是覆盖在此示例中将鼠标悬停在链接1上时显示的div?我已经尝试更改段落和列表的z-index,但没有任何作用。真正让我不理解的事实是,在过渡期间,列表出现在段落上。然后,在转换之后,段落似乎改变了z-index。任何帮助都会很棒。

div {
  background-color: #BFBFBF;
  height: 50px;
  width: 100%;
  z-index: 1;
}
.NavList {
  list-style: none;
  margin: 0;
  padding: 0;
}
.NavListItem {
  display: inline-block;
  text-align: center;
  float: left;
}
.NavListItem:Hover .NavLink {
  display: block;
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100px;
  color: #BFBFBF;
  text-decoration: none;
  background-color: #7F7F7F;
  transition: background-color .5s;
}
.NavLink {
  display: block;
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100px;
  color: #BFBFBF;
  text-decoration: none;
  background-color: #404040;
  transition: background-color .5s;
}
.NavListItem:Hover .SubNavList {
  display: block;
  list-style: none;
  margin: 0;
  padding: 0;
  opacity: 1;
  z-index: 100;
  transition: opacity 5s;
}
.NavListItem:Hover .SubNavListItem {
  display: block;
  text-align: center;
}
.NavListItem:Hover .SubNavLink {
  display: block;
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100px;
  color: #BFBFBF;
  text-decoration: none;
  background-color: #7F7F7F;
  transition: background-color .5s;
}
.NavListItem:Hover .SubNavLink:Hover {
  display: block;
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100px;
  color: #BFBFBF;
  text-decoration: none;
  background-color: #404040;
  transition: background-color .5s;
}
.SubNavList {
  display: block;
  width: 0px;
  height: 0px;
  opacity: 0;
  transition: opacity 5s;
  z-index: 100;
}
.SubNavListItem {
  display: none;
}
p {
  z-index: -1;
}
<body>
  <div>
    <ul class="NavList">
      <li class="NavListItem">
        <a href="#" class="NavLink">Home</a>
      </li>
      <li class="NavListItem">
        <a href="#" class="NavLink">Link 1</a>
        <ul class="SubNavList">
          <li class="SubNavListItem">
            <a href="#" class="SubNavLink">SubLink 1</a>
          </li>
          <li class="SubNavListItem">
            <a href="#" class="SubNavLink">SubLink 2</a>
          </li>
        </ul>
      </li>
      <li class="NavListItem">
        <a href="#" class="NavLink">Link 2</a>
        <ul class="SubNavList">
          <li class="SubNavListItem">
            <a href="#" class="SubNavLink">SubLink 3</a>
          </li>
          <li class="SubNavListItem">
            <a href="#" class="SubNavLink">SubLink 4</a>
          </li>
        </ul>
      </li>
      <li class="NavListItem">
        <a href="#" class="NavLink">Link3</a>
      </li>
    </ul>
  </div>
  <p>Lorem ipsum dolor sit amet</p>
</body>

更多相关文章

  1. 【WEB基础】HTML & CSS 基础入门(3)段落及文本
  2. 动态更改angularjs中静态段落的颜色
  3. Python Module之textwrap - 文本段落格式编排

随机推荐

  1. android install
  2. Android 中插件的编写方法
  3. android开发之布局常用属性
  4. 安卓中RelativeLayout布局
  5. Android异步处理一:使用Thread+Handler实
  6. Android中EditText的inputType属性值
  7. Android与JavaScript相互调用(Android和h
  8. 相对布局中一些常用属性
  9. Android 相对布局 RelativeLayout 属性 (
  10. Android下创建一个sqlite数据库