我想做一個菜單,其中包含一個菜單項與下拉菜單,但我似乎無法得到它非常正確。 我開始將現有的菜單欄與一段代碼合併爲一個下拉菜單,我已經設法在菜單欄中拖放下拉菜單項,但是我不知道如何讓菜單欄重新回到頂部它左側仍然有空白。 我的下拉菜單中還有一個額外的空項目,我不知道如何擺脫它?下拉菜單不起作用我想要它
是否有人可以幫助我,我覺得我忽視的東西
.menu-bar {
position: fixed;
width: 100vw;
background-color: #134c95;
color: white;
display: flex;
flex-direction: row;
justify-content: center;
opacity: 0.8;
}
.menu-item {
padding: 10px;
cursor: default;
font-size: 15pt;
margin-left: 15px;
margin-right: 15px;
}
.menu-item:hover,
a:hover {
background-color: white;
cursor: pointer;
color: 234c95;
}
.menu-bar a {
color: white;
}
.menu-bar a:visited {
color: white;
}
.menu-bar a:link,
.menu-bar a:visited {
text-decoration: none;
}
/*
.menu-bar a:hover {
color: #134c95;
}
*/
/* Dropdown Button */
.dropbtn {
background-color: inherit;
color: white;
/* padding: 16px;*/
/* font-size: 16px;*/
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
/*
.dropdown {
position: fixed;
display: inline-block;
}
*/
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: white;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
/* z-index: 1;*/
}
/* Links inside the dropdown */
.dropdown-content a {
color: #234c95;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
background-color: 234c95;
color: white;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: white;
color: #234c95;
}
<div class="menu-bar">
<a href="instructiestest.html">
<div class="menu-item">Welkom</div>
</a>
<a href="instructie2.html">
<div class="menu-item">Aanmelden Portbase</div>
</a>
<a href="instructie3.html">
<div class="menu-item">De App</div>
</a>
<a href="testing.html">
<div class="dropdown">
<button class="dropbtn">
<div class="menu-item">Het team</div>
<div class="dropdown-content">
<a href="http://google.com" target="_blank">Google</a>
<a href="http://facebook.com" target="_blank">Facebook</a>
<a href="http://youtube.com" target="_blank">YouTube</a>
</div>
</button>
</div>
</a>
</div>
Thankyou :)我總是有這個時候,我編了幾個小時,我傾向於忽略像標籤這樣的小細節。最後,這個空的鏈接消失了! – xoMK