Curry_warrior 2020-03-15 09:15 采纳率: 50%
浏览 441
已采纳

加了背景图在网页过后导航栏点击失效

小弟在未加背景图前的网页如下图所示,可以看见鼠标移至导航栏时会有选项供选择

图片说明

但是在加了背景图后,导航栏无法选择了,只能看到导航栏显示出来
图片说明

能请教下如何修复这个问题吗。
下面是我的代码:
图片说明

css文件代码:

html {
    height: 100%;
}
.top{
    /* 设置宽度高度背景颜色 */
    height: auto; /*高度改为自动高度*/
    width:100%;
    margin-left: 0;
    background:rgb(189, 181, 181);
    position: fixed; /*固定在顶部*/
    top: 0;/*离顶部的距离为0*/
    margin-bottom: 5px;
      z-index:-10;
}
.top ul{
    /* 清除ul标签的默认样式 */
    width: auto;/*宽度也改为自动*/
    list-style-type: none;
    white-space:nowrap;
    overflow: hidden;
    margin-left: 5%;
    /* margin-top: 0;          */
    padding: 0;

}
.top li {
    float:left; /* 使li内容横向浮动,即横向排列  */
    margin-right:6%;  /* 两个li之间的距离*/
    position: relative;
    overflow: hidden;
}

.top li a{
   /* 设置链接内容显示的格式*/
    display: block; /* 把链接显示为块元素可使整个链接区域可点击 */
    color:white;
    text-align: center;
    padding: 3px;
    overflow: hidden;
    text-decoration: none; /* 去除下划线 */

}
.top li a:hover{
    /* 鼠标选中时背景变为黑色 */
    background-color: #111;
}
.top ul li ul{
    /* 设置二级菜单 */
    margin-left: -0.2px;
    background:rgb(189, 181, 181);
    position: relative;
    display: none; /* 默认隐藏二级菜单的内容 */

}
.top ul li ul li{
    /* 二级菜单li内容的显示 */

    float:none;
    text-align: center;
}
.top ul li:hover ul{
    /* 鼠标选中二级菜单内容时 */
    display: block;
}

h1{
 font-size: 50px;
 letter-spacing:1px;
 position:absolute;
 top:50%;
 left:50%;
 transform: translate(-50%, -50%);
 margin:0;
 background:url(yellow_background.jpg) 30% 30%;
 background-size: cover;
 -webkit-text-fill-color:transparent;
 -webkit-background-clip: text;
 }

body {
    height: 100%;
    background-image:url("Background1.jpg");
    background-repeat: no-repeat;
    background-size: 100% 100%;
      z-index:-1;
     margin:0px;
    padding:0px;

}
  • 写回答

1条回答 默认 最新

  • 长河落雨 2020-03-15 09:54
    关注

    z-index覆盖了?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题