我想樣式菜單欄的顏色。 如果li是「active」,那麼文本顏色和邊框顏色應該是藍色的,否則一切都是灰色的。 懸停時,灰色應變成藍色。CSS/HTML文本onhover不會改變
我試過了,但不起作用。這是我的代碼:
@import 'https://fonts.googleapis.com/css?family=Fjalla+One';
ul.dnav {
list-style-type: none;
margin-left: 0px;
margin-right: 0px;
overflow: hidden;
width: 400px;
-webkit-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
-moz-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
}
li.dnav {
font-size: 20px;
background-color: #FFF;
width: 100px;
float: left;
margin-top: 10px;
margin-right: 10px;
margin-left: 10px;
margin-bottom: 0px;
border-style: solid;
border-color: grey;
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
}
li.dnav a {
color: grey;
font-family: 'Fjalla One', sans-serif;
display: block;
text-align: center;
padding: 10px 10px;
text-decoration: none;
}
li.dnav a:hover {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
border-color: rgba(0, 130, 255, 1);
}
a:active {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
}
li.dnav-active {
border-color: rgba(0, 130, 255, 1);
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
color: rgba(0, 130, 255, 1);
}
<header>
<ul class="dnav">
<li class="dnav dnav-active"><a class="active" href="#">Home</a>
</li>
<li class="dnav"><a href="#">ser</a>
</li>
<li class="dnav"><a href="#">con</a>
</li>
</ul>
</header>
只是改變'li.dnav-active'行'li.dnav活性,li.dnav:hover' – bharat