水平导航,用CSS编写。
预期行为:将鼠标悬停在主列表项上时显示子菜单
问题:IE11 忽略列表项的悬停规则
.desktop-header ul li > ul {
background: #fff;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
visibility: hidden;
opacity: 0;
min-width: 100%;
position: absolute;
margin-top: 5px;
left: 0;
padding-top: 5px;
display: none;
padding-bottom: 10px;
}
.desktop-header ul li:hover > ul,
.desktop-header ul li:focus-within > ul,
.desktop-header ul li ul:hover,
.desktop-header ul li ul:focus {
visibility: visible;
opacity: 1;
display: block;
}
JSFIDDLE: https://jsfiddle.net/dauwrsm2/3/
这似乎是focus-within
选择器的问题。 如果将 CSS 更改为以下内容,它将起作用:
.desktop-header ul li:hover > ul,
.desktop-header ul li:focus > ul,
.desktop-header ul li ul:hover,
.desktop-header ul li ul:focus {
visibility: visible;
opacity: 1;
display: block;
}