我一直在试图让我的导航栏响应。到目前为止,我设法在屏幕变小时显示彼此之下的所有li项目。然而,我的导航栏中的某些li有通常会下降的子项(类有3个子li)。当悬停其中一个具有子条目的li时,它将呈现它们通过导航栏的主li项。当设置为响应时,通过其他li元素显示的导航栏的下拉部分
我想要的是子菜单不会被悬停触发,但只有当用户点击他们的屏幕。之后,它应该显示父li下面的子菜单项,然后继续其他主li。
下面的代码是全屏导航栏的工作部分。
.nav a {
text-decoration: none;
color: #fff;
display: inline-block;
padding-left: 15px;
padding-right: 15px;
border-bottom: none;
transition: .5s background-color;
}
.nav ul {
list-style: none;
background-color: #522d54;
text-align: center;
padding: 0;
margin: 0;
display: block;
}
.nav li {
font-family: 'Allerta', Helvetica, Arial, sans-serif;
width: auto;
line-height: 40px;
border-bottom: none;
font-size: 1em;
display: inline-block;
text-align: left;
}
.nav a:hover {
background-color: #39203b;
}
.nav a.active {
cursor: default;
background-color: #824885;
box-shadow: inset 0em -.2em #b084b3;
}
.nav ul li {
position: relative;
display: inline-block;
}
.nav ul li ul li {
text-align: center;
padding: 0;
width: 100%;
}
.nav li ul li a {
text-align: left;
font-size: .8em;
white-space: nowrap;
padding-left: 15px;
padding-right: 15px;
display: block;
}
.nav ul li ul {
position: absolute;
display: none;
width: inherit;
}
.nav li:hover ul {
display: inline-block;
}