1
我目前正試圖通過添加下拉菜單來擴展我的導航欄。我嘗試了一切,但似乎沒有任何工作。有沒有什麼方法可以添加下拉功能,而無需重新創建我的整個導航欄?如何在HTML/PHP中爲導航欄創建下拉菜單?
div.content a:link {
color: #000000;
text-decoration: normal;
}
div.content a:visited {
color: #000000;
text-decoration: normal;
}
div.content a:hover {
color: #383838;
text-decoration: normal;
-o-transition: .3s;
-ms-transition: .3s;
-moz-transition: .3s;
-webkit-transition: .3s;
transition: .3s;
}
div.content a:active {
color: #000000;
text-decoration: normal;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #595959;
max-width: 950px;
min-width: 900px;
margin: auto;
box-shadow: 0px 0px 5px #000000;
margin-bottom: 15px;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
font-style: normal;
padding: 14px 16px;
text-decoration: none;
-o-transition: .3s;
-ms-transition: .3s;
-moz-transition: .3s;
-webkit-transition: .3s;
transition: .3s;
}
li a:hover {
background-color: #404040;
}
<div class="nav">
<ul>
<li><a href="/">Home</a>
</li>
<li><a href=";insertyoutubechannel;">YouTube</a>
</li>
<li><a href=";inserttwitter;">Twitter</a>
</li>
<li><a href="/services">Services</a>
</li>
<li><a href="/contact">Contact</a>
</li>
</ul>
</div>
你能提供你有*什麼試過代碼*?最簡單的方法是將一個ul包裝在li中,並且該子菜單通過懸停時觸發的「display:none」進行絕對定位,具有可選的過渡效果 – Aziz