把css课变成了mixin

时间:2014-05-06 12:40:33

标签: css twitter-bootstrap mixins saas

以下是我的css代码。

div {
 &:before {
    position: absolute;
    width: 48%;
    height: 10px;
    content: ' ';
    left: 20px;
    bottom: 40px;
    @include vendor(transform, top);
    @include vendor(transform, skew(-5deg) rotate(-3deg));
    @include vendor(box-shadow, 0 30px 4px 10px red);
    z-index: -1;
  }
}

以下是我的混音。

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

是否可以将整个前块代码转换为通用mixin,如add-effect

1 个答案:

答案 0 :(得分:2)

@mixin add-effect {
 &:before {
    position: absolute;
    width: 48%;
    height: 10px;
    content: ' ';
    left: 20px;
    bottom: 40px;
    @include vendor(transform, top);
    @include vendor(transform, skew(-5deg) rotate(-3deg));
    @include vendor(box-shadow, 0 30px 4px 10px red);
    z-index: -1;
  }
}