今天在写下拉菜单的时候发现:当鼠标进入下拉菜单时,下拉菜单消失。
在网上找了许多方法都无法解决。最后发现是downMenu下面的搜索框把userInfo盖住了(看起来没盖住,但在图层上开在userInfo的上面)。
//userInfo的父亲盒子
.shortcut {
z-index: 100;
margin-bottom: 10px;
height: 40px;
line-height: 40px;
background-color: rgba(245, 245, 245, 1);
}
//盖住userinfo的盒子
.header {
z-index: 50;
position: relative;
width: 1100px;
margin: 0 auto;
height: 110px;
}
原因:header有相对定位。
解决方案:给.shortcut 加 相对定位
。