0
我試圖修復我的菜單代碼,以便當我將鼠標懸停在按鈕上時,下拉菜單將與按鈕的左邊緣一致。現在它像列表一樣向右間隔一點。如何將菜單下拉內容移動到與按鈕的左邊緣一致?
HTML:
<center>
<div class="menubar">
<button class="button">Forms
<div class="menubar-content">
<a href="#">Department Update Form</a>
<a href="#">Project Start Month Form</a>
<a href="#">Add New Employee Form</a>
</div>
</button>
<button class="button">Reports
<div class="menubar-content">
<a href="#">Human Resource's Employees Report</a>
</div>
</button>
<button class="button">Reports
<div class="menubar-content">
<a href="#">Human Resource's Employees Report</a>
<a href="#">2012 04 Product Plan Project Report</a>
<a href="#">Department Data Report</a>
<a href="#">Employee Business Info Report</a>
<a href="#"></a>
</div>
</button>
</div>
</center>
CSS:
.button {
background-color: blue;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
margin:5px;
}
.menubar {
position: relative;
display: inline-block;
}
.menubar-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 200px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
margin: 16px;
}
.menubar-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.menubar-content a:hover {
background-color: #f1f1f1;
}
.button:hover .menubar-content {
display: block;
}
.menubar:hover .dropbtn {
background-color: #3e8e41;
}
非常感謝!我從來沒有這樣做過。 – Jeremy
沒有問題。如果能夠工作,你是否介意接受我的答案是正確的,以幫助後來發現此問題的人? – amflare
當然!儘管如此,您在保證金餘額後錯過了冒號。別擔心。 – Jeremy