【问题标题】:Are mixin parenthesis optional when nested?嵌套时mixin括号是可选的吗?
【发布时间】:2016-05-04 18:52:01
【问题描述】:

考虑以下几点:

.flashing {

    .flashKeyFrames(fade-in;{
        0%, 100% {opacity: 1;}
        50% {opacity: 0;}
        });

    .flashing(fade-in linear infinite alternate; 1s)

}

.flashKeyFrames(@name; @arguments) {
    @-moz-keyframes @name { @arguments(); }
    @-webkit-keyframes @name { @arguments(); }
    @keyframes @name { @arguments(); }
}

.flashing(@arguments, @duration) {
    -webkit-animation: @arguments;
    -moz-animation: @arguments;
    animation: @arguments;

    -webkit-animation-duration: @duration;
    -moz-animation-duration: @duration;
    animation-duration: @duration;
}

@arguments 后面的括号必须是什么?我认为当用作 mixins 时括号是可选的?所以我假设@arguments 没有被定义为mixin,但那是什么?

【问题讨论】:

    标签: less less-mixins


    【解决方案1】:

    不,.flashKeyFrames 中使用的 @arguments 不是 mixin。它是传递给mixin的参数。设置为此参数的值集是detached ruleset,并且要使分离的规则集调用起作用,末尾的括号() 是必需的。以下是 Less 网站的摘录:

    分离的规则集调用后的括号是强制性的。调用 @detached-ruleset; 不起作用。

    只有在调用 mixin 而不是规则集时,括号才不是可选的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-11
      • 2023-03-16
      • 2015-12-11
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      • 2011-09-20
      相关资源
      最近更新 更多