首页 > 解决方案 > 在 Sass 文件中创建 Mixin

问题描述

这是我的代码,我想在我的 sass 文件中创建 mixins

=shaping($height , $width, $rad, $bg, $color)

height:                     $height

width:                      $width

-webkit-border-radius:      $rad

-moz-border-radius:         $rad

-ms-border-radius:          $rad

background-color:           $bg

border-radius:              $rad

color:                      $color

但是编译的时候出现这个错误,不知道是什么问题,谁能帮帮我?是因为语法吗?

error: properties are only allowed within rules, directives, mixin includes or other properties

标签: htmlcsssass

解决方案


=shaping($height, $width, $rad, $bg, $color)
  height: $height
  width: $width
  -webkit-border-radius: $rad
  -moz-border-radius: $rad
  -ms-border-radius: $rad
  border-radius: $rad
  background-color: $bg
  color: $color

.element
  +shaping(50px, 50px, 10px, #000, #fff) 

在选择器之后,换行。例如

.element
      +shaping

推荐阅读