只要將鼠標懸停在按鈕上,我希望看到下拉菜單,但是當我按下按鈕時,我只能看到其中的一半。我在代碼中做錯了什麼?使用HTML和CSS的簡單下拉菜單
代碼:
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
body {
background-color: #1A1617
}
ul {
text-align: center;
list-style-type: 0px;
margin: 0px;
padding: 20px;
background-color: black;
overflow: hidden;
}
li a {
color: white;
padding: 8px 16px;
text-decoration: none;
}
li {
display: inline;
}
li a:hover {
background-color: red;
text-size: 10px;
}
.dropdown:hover .dropdown-content {
display: block;
}
<!DOCTYPE html>
<html>
<body>
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="news.html">News</a></li>
<div class="dropdown">
<li><a href="about.html">About</a></li>
<div class="dropdown-content"><p>Check</p></div>
</div>
</ul>
</body>
</html>