當你將鼠標懸停在導航欄,按鈕應該改變顏色。UL在DIV不會更新高度
然而,在我的情況下,該按鈕改變顏色,但它不會做這樣一路導航欄的底部(你仍然可以看到下黑一些灰色)。
如何讓這個它一路走到底部?
而且,由於某些原因,它會在谷歌瀏覽器一路下跌,而不是在其他瀏覽器。
的index.html
<div id ="nav">
<ul id = "navbar" class = "navigationbar">
<li class="dropdown">
<a href="#" class="dropbtn">Dropdown1</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
<li class="dropdown">
<a href="#" class="dropbtn">Dropdown2</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
<li class="dropdown">
<a href="#" class="dropbtn">Dropdown3</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
<li class = "dropdown">
<a href="#" class="dropbtn">Not Dropdown</a>
</li>
</ul>
</div>
和style.css的
html { width:100%; height:100%; margin:0 padding:0;}
body { width:100%; height:100%; margin:0; padding:0; }
#nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color:lightslategray;
min-width: 100%;
list-style: none;
display: inline-block;
height: 100%;
}
#nav li {
height:100%;
vertical-align: middle;
line-height: 300%;
list-style: none;
display: inline-block;
}
#nav{
width: 100%;
display:table;
margin:0 auto;
text-align: center;
background-color: lightslategray;
}
.dropdown a{
height: 65%;
display: inline-block;
font-family: "Palatino Linotype";
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 18px;
}
.dropbtn{
height: 100%;
display: inline-block;
font-family: "Palatino Linotype";
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 18px;
}
.dropdown a:hover, .dropdown:hover .dropbtn {
background-color:black;
color: white;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
z-index: 20;
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1; color: black;}
.dropdown:hover .dropdown-content {
display: block;
}
不明白的問題。 https://jsfiddle.net/un6vcgqz/ –
它有什麼作用? Safari接縫也可以。 – Gabriela
對於我來說,如果你將鼠標懸停在選項(尤其是與非下拉明顯),黑色也不會完全深入到導航欄的底部。 (感謝使jsfiddle順便說一句!) –