2016-03-11 138 views
0

我是CSS和HTML的新手,遇到了一個讓我完全陷入困境的問題 - 我應用於導航欄的過渡效果看起來並不像生效。我尋找了一個無濟於事的答案,並且準備在這一點上打破一些東西。以下是我的導航欄的CSS。CSS過渡效果不起作用

ul { 
    list-style-type: none; 
    margin: 0; 
    padding: 0; 
    overflow: hidden; 
    background-color: #333; 
    text-align: center; 
} 

li { 
    display: inline-block; 
    font-family: 'Oswald Light', Verdana, Geneva, sans-serif; 
    font-size: 20px; 
    background-color: #333; 
    -webkit-transition: all 0.9s ease; 
    -moz-transition: all 0.9s ease; 
    -o-transition: all 0.9s ease; 
    -ms-transition: all 0.9s ease; 
    transition: all 0.9s ease; 
} 

li a { 
    display: inline-block; 
    color: white; 
    text-align: center; 
    padding: 14px 16px; 
    text-decoration: none; 
} 

li a:hover { 
    background-color: #6699cc; 
} 

回答

0

你應該更換你的代碼轉換爲LI {} 因此這將是水木清華這樣的:

li a { 
display: inline-block; 
color: white; 
text-align: center; 
padding: 14px 16px; 
text-decoration: none; 
-webkit-transition: all 0.9s ease; 
-moz-transition: all 0.9s ease; 
-o-transition: all 0.9s ease; 
-ms-transition: all 0.9s ease; 
transition: all 0.9s ease; 
} 
+0

它的工作原理!非常感謝! – Zeiphex

0

你的CSS編輯:

ul { 
list-style-type: none; 
margin: 0; 
padding: 0; 
overflow: hidden; 
background-color: #333; 
text-align: center; 
} 

li { 
display: inline-block; 
font-family: 'Oswald Light', Verdana, Geneva, sans-serif; 
font-size: 20px; 
background-color: #333; 

} 

li a { 
display: inline-block; 
color: white; 
text-align: center; 
padding: 14px 16px; 
text-decoration: none; 
-webkit-transition: all 0.9s ease; 
-moz-transition: all 0.9s ease; 
-o-transition: all 0.9s ease; 
-ms-transition: all 0.9s ease; 
transition: all 0.9s ease; 
} 

li a:hover { 
background-color: #6699cc; 
} 
+0

謝謝!這樣可行! – Zeiphex