vsi*_*ege 9 mixins less css-transitions
可有人告诉怎么用以下数值混入过渡下列财产.25s与线性放心?
border-top:6px solid#ff3300;
.transition-properties(...) {
@props: ~`"@{arguments}".replace(/[\[\]]/g, '')`;
-webkit-transition-property: @props;
-moz-transition-property: @props;
-o-transition-property: @props;
transition-property: @props;
}
Run Code Online (Sandbox Code Playgroud)
Sco*_*ttS 28
使用LESS 1.4,不需要在逗号分隔参数的原始答案中使用的javascript.相反,在参数字符串末尾使用"虚拟"分号会导致逗号被视为列表分隔符,而不是参数分隔符,因此现在可以在输入多个转换时使用:
mixin call(.transition-properties(border-top .25s linear, color .5s linear;);)中的分号非常重要.如果它被省略,则将删除两个参数之间的逗号,这将以无效的css规则结束.
.transition-properties(...) {
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
transition: @arguments;
}
.yourClass {
border-top: 1px solid black;
.transition-properties(border-top .25s linear, color .5s linear;); /* semicolon is necessary */
} |
NOTE THIS SEMICOLON
.yourClass:hover {
border-top: 6px solid #ff3300;
}
Run Code Online (Sandbox Code Playgroud)
请注意,逗号位于两个属性值之间:
.yourClass {
border-top: 1px solid black;
-webkit-transition: border-top 0.25s linear, color 0.5s linear;
-moz-transition: border-top 0.25s linear, color 0.5s linear;
-o-transition: border-top 0.25s linear, color 0.5s linear;
transition: border-top 0.25s linear, color 0.5s linear;
}
.yourClass:hover {
border-top: 6px solid #ff3300;
}
Run Code Online (Sandbox Code Playgroud)
显然,细节取决于您的确切实施.但是,这一般说明了如何使用它:
.transition-properties(...) {
@props: ~`"@{arguments}".replace(/[\[\]]/g, '')`;
-webkit-transition: @props;
-moz-transition: @props;
-o-transition: @props;
transition: @props;
}
.yourClass {
border-top: 1px solid black;
.transition-properties(border-top .25s linear);
}
.yourClass:hover {
border-top: 6px solid #ff3300;
}
Run Code Online (Sandbox Code Playgroud)
.yourClass {
border-top: 1px solid black;
-webkit-transition: border-top 0.25s linear;
-moz-transition: border-top 0.25s linear;
-o-transition: border-top 0.25s linear;
transition: border-top 0.25s linear;
}
.yourClass:hover {
border-top: 6px solid #ff3300;
}
Run Code Online (Sandbox Code Playgroud)
什么的
@props: ~`"@{arguments}".replace(/[\[\]]/g, '')`;
Run Code Online (Sandbox Code Playgroud)
允许你做的是放入多个逗号分隔的转换,比如说:
.transition-properties(border-top .25s linear, color 1s linear);
Run Code Online (Sandbox Code Playgroud)
哪个将编译以使它们用逗号分隔(例如只显示一行):
transition: border-top 0.25s linear, color 1s linear;
Run Code Online (Sandbox Code Playgroud)
如果您刚刚使用直线@arguments,最终没有逗号分隔:
transition: border-top 0.25s linear color 1s linear;
Run Code Online (Sandbox Code Playgroud)
哪个属性不正确.