首页 > sass中Mixins中each循环的问题

sass中Mixins中each循环的问题

@mixin css3($property, $value) {
    @each $prefix in -webkit-, -moz-, -ms-, -o-, '' {
        #{$prefix}#{$property}: $value;
    }
}
@mixin css3after($property, $value) {
    @each $prefix in -webkit-, -moz-, -ms-, -o-, '' {
        $property: #{$prefix}#{$value};
    }
}




header{
    @include css3after(display,box);
}
.border_radius {
  @include css3(transition, 0.5s);
}

为什么 .border_radius 的引用是成功的,但是 header的就是失败的??

.border_radius成功后是这样的:

   .border_radius {
      -webkit-transition: 0.5s;
      -moz-transition: 0.5s;
      -ms-transition: 0.5s;
      -o-transition: 0.5s;
      transition: 0.5s;
    }

@mixin css3after($property, $value) {
    @each $prefix in -webkit-, -moz-, -ms-, -o-, '' {
        #{$property}: #{$prefix}#{$value};
    }
}

这样试试,属性名应该用这种形式

【热门文章】
【热门文章】