为什么 css 过渡不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17097348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
why css transition doesn't work
提问by iKamy
I'm trying to add transition but it doesnt work I added transition to my links and expect changes on hover state I used transition alot, but some times this happens to me and I dont know why this property doesnt work
我正在尝试添加过渡,但它不起作用我向链接添加了过渡并期望悬停状态发生变化我经常使用过渡,但有时这发生在我身上,我不知道为什么这个属性不起作用
I prefer to know why it doesnt work
我更想知道为什么它不起作用
this is my code
这是我的代码
<div class="subNavigation">
<ul>
<li>?????? ???? ???</li>
<li><a href="javascript:void(0)">?????? ???? ??? 1</a></li>
<li><a href="javascript:void(0)">?????? ???? ??? 2</a></li>
<li><a href="javascript:void(0)">?????? ???? ??? 3</a></li>
<li><a href="javascript:void(0)">?????? ???? ??? 4</a></li>
</ul>
</div>
and css
和CSS
.subNavigation {
width: 900px;
height: 274px;
position: absolute;
top: 40px;
right: 0;
padding: 30px 60px 0 0;
}
/* line 126, ../sass/style.scss */
.subNavigation ul {
float: right;
}
/* line 130, ../sass/style.scss */
.subNavigation li {
width: 153px;
*zoom: 1;
margin-top: 4px;
padding-right: 2px;
padding-bottom: 4px;
border-bottom: 1px dotted #b4b4b4;
}
/* line 38, D:/Ruby193/lib/ruby/gems/1.9.1/gems/compass- 0.12.2/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
.subNavigation li:after {
content: "";
display: table;
clear: both;
}
/* line 138, ../sass/style.scss */
.subNavigation li:first-child {
width: 155px;
height: 24px;
margin-top: 0;
margin-bottom: 14px;
color: #f7931e;
border-bottom: 1px solid #dddddd;
padding-right: 0;
font-size: 16px;
line-height: 24px;
}
/* line 151, ../sass/style.scss */
.subNavigation a {
float: right;
font-size: 13px;
height: 24px;
line-height: 24px;
padding-right: 2px;
color: #222;
-webkit-transition: all, 0.2s, ease-in;
-moz-transition: all, 0.2s, ease-in;
-o-transition: all, 0.2s, ease-in;
transition: all, 0.2s, ease-in;
}
/* line 160, ../sass/style.scss */
.subNavigation a.eng {
font-family: tahoma;
}
/* line 164, ../sass/style.scss */
.subNavigation a:hover {
padding-right: 10px;
border-right: 4px solid #f7941d;
color: #19ae61;
}
回答by RaphaelDDL
One simple error:
一个简单的错误:
-webkit-transition: all, 0.2s, ease-in;
-moz-transition: all, 0.2s, ease-in;
-o-transition: all, 0.2s, ease-in;
transition: all, 0.2s, ease-in;
Change to:
改成:
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
Demo: http://jsfiddle.net/X5UBF/1/
演示:http: //jsfiddle.net/X5UBF/1/
Transition values are not comma separated. They are a single declaration. If you want to declare multiple transitions, THEN you comma separate them.
转换值不是逗号分隔的。它们是一个单一的声明。如果你想声明多个转换,那么你用逗号分隔它们。
Value: <single-transition> [ ‘,' <single-transition> ]*
Where <single-transition>
is:
在哪里<single-transition>
:
<single-transition> = <transition-property> <transition-duration> <transition-timing-function> <transition-delay>
So, a comma separated example would be:
因此,逗号分隔的示例是:
transition: opacity 0.5s ease-in, width 1.5s ease-out;
/* 0.5s for an opacity transform while 1.5s for a width transform */
回答by David Nguyen
Improper declaration of transition:
不正确的过渡声明:
-webkit-transition: all 0.2s ease-in; /* Chrome 1-25, Safari 3.2+ */
-moz-transition: all 0.2s ease-in; /* Firefox 4-15 */
-o-transition: all 0.2s ease-in; /* Opera 10.50–12.00 */
transition: all 0.2s ease-in; /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */