0
我遇到問題,無法解決問題。 我已經創建了這個HTML頁面,但#drop
上的:hover
選擇器不起作用。下拉列表不起作用html css
#drop {
display: inline-block;
color: white;
background-color: #4CAF50;
padding: 10px;
}
#droplist {
display: none;
position: absolute;
z-index: 1;
}
#droplist a {
display: block;
text-decoration: none;
color: white;
background-color: olivedrab;
padding: 10px;
}
#drop:hover #droplist {
display: block;
}
#droplist a:hover {
background-color: olive;
}
<!DOCTYPE html>
<html lang="it">
<!-- ... -->
<body>
<div id="pagina">
<div id="drop">Hover for open the menu</div>
<div id="droplist">
<a href="#a">Link 1</a>
<a href="#b">Link 2</a>
<a href="#c">Link 3</a>
</div>
<br/>text text text text text text text text text
</div>
</body>
</html>
我嘗試用ID #drop
懸停在div但該元素#droplist
不出來。
沒問題Matteo,看看我上面的編輯(在你的代碼中添加'#droplist:hover {display:block}')。同時考慮爲未來的用戶提供答案並接受答案。謝謝! – Ivan