2016-03-11 231 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