【发布时间】:2021-07-28 14:21:17
【问题描述】:
我正在为网站制作标题,但遇到了问题。在屏幕的左侧我有一些文本,右侧是一个语言选择菜单,使用下拉菜单。但是,如果我将鼠标悬停在整个标题上,下拉菜单就会展开。我只希望在我实际将鼠标悬停在语言选择上时发生这种情况。这里有一些代码:
header > h1 {
font-weight: bold;
font-size: 40px;
margin-left: 30px;
margin-top: 4%;
}
#hr1 {
background-color: #FFF;
height: 3px;
width: 50%;
margin-left: 30px;
margin-top: 10px;
}
.dropdown {
text-align: right;
margin-right: 30px;
margin-top: -57px;
background: pink;
}
.dropdown-div {
font-weight: bold;
font-size: 40px;
color: #FFF;
cursor: pointer;
}
.dropdown-items {
display: none;
}
.dropdown:hover .dropdown-items {
display: block;
}
.dropdown-items > button {
background-color: #0E3854;
border: none;
cursor: pointer;
}
.dropdown-items #dropdown-item1 {
display: none;
margin-bottom: 10px;
}
.dropdown-item {
display: block;
color: #FFF;
font-size: 20px;
margin-top: 10px;
margin-left: auto;
}
#dropdown-item2 {
margin-bottom: 10px;
}
#hr2 {
background: #FFF;
height: 3px;
width: 7%;
margin-left: auto;
margin-right: 30px;
margin-top: -3px;
}
<header>
<h1>The right side of the page</h1>
</header>
<hr id="hr1">
<div class="dropdown">
<h1 class="dropdown-div" id="dropdown-div-text">Taal</h1>
<div class="dropdown-items">
<button onclick="languageSelectDutch()" class="dropdown-item" id="dropdown-
item1">Nederlands</button>
<button onclick="languageSelectEnglish()" class="dropdown-item" id="dropdown-
item2">Engels</button>
</div>
</div>
希望有人有解决方案!
【问题讨论】: