【发布时间】:2019-12-18 02:26:24
【问题描述】:
我刚刚构建了我的导航栏,但下拉菜单有一个小问题。下拉菜单出现在悬停时,但是当我尝试将鼠标从导航栏上的顶部链接移动到下方的下拉菜单时,下拉菜单消失了,因此我无法实际点击任何链接。
我该如何解决这个问题?
CSS
/* Navbar */
h1 {
color: white;
font-family: 'Great Vibes', cursive;
margin-left: 30px;
font-size: 45px;
text-align: left;
margin-top: -57px;
}
.navbar {
background: rgba(179, 173, 140);
font-family: 'Hind', sans-serif;
height: 4.5rem;
width: 1280px;
margin-top: -8px;
margin-left: -8px;
}
/* Links inside the navbar */
.navbar a {
float: right;
font-size: 18px;
color: white;
line-height: 44px;
padding: 14px 16px;
text-decoration: none;
}
/* The dropdown container */
.dropdown {
float: right;
overflow: hidden;
}
.retreat-dropdown {
color: white;
font-size: 18px;
position: relative;
margin-top: 26px;
}
.navbar a:hover, .dropdown:hover {
text-decoration: underline white;
}
/* Links inside the dropdown */
.dropdown-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
font-family: 'Hind', sans-serif;
}
.dropdown-content a:hover {
background-color: rgb(197, 192, 166);
}
/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background: rgb(160, 189, 127);
font-family: 'Hind', sans-serif;
z-index: 1;
margin-top: 20px;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
margin-left: -30px;
}
#page-container {
position: relative;
min-height: 100vh;
}
【问题讨论】: