为什么我的sass没有编译成css?
我是sass的新手,目前正在探索它。我想尝试使用mixin,但当我尝试时,它就是不起作用。代码如下:为什么我的sass没有编译成css?,sass,scss-mixins,Sass,Scss Mixins,我是sass的新手,目前正在探索它。我想尝试使用mixin,但当我尝试时,它就是不起作用。代码如下: @mixin container($radius, $width, $height, $bg, $color) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius; $width:
@mixin container($radius, $width, $height, $bg, $color) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
$width: $width;
$height: $height;
$bg: $bg;
$color: $color;
margin: 0 auto;
}
.container {
@include container(10px, 80%, 700px, $white, $dark-grey)
}
所以我有一个div和class容器,想把mixin放在里面,但它就是不起作用。有人能帮忙吗???看起来你的变量有点乱 这应该起作用:
@mixin container($radius, $width, $height, $bg, $color) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
width: $width; // <= here
height: $height; // <= here
background-color: $bg; // <= here
color: $color;
margin: 0 auto;
}
.container {
@include container(
10px,
80%,
700px,
white, // <= here
darkgrey // <= here
)
}
看起来你的变量有点乱 这应该起作用:
@mixin container($radius, $width, $height, $bg, $color) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
width: $width; // <= here
height: $height; // <= here
background-color: $bg; // <= here
color: $color;
margin: 0 auto;
}
.container {
@include container(
10px,
80%,
700px,
white, // <= here
darkgrey // <= here
)
}
这个
$white: #fff;
$dark-grey: #666;
@mixin container($radius, $width, $height, $bg, $color) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
width: $width;
height: $height;
background: $bg;
color: $color;
margin: 0 auto;
}
.container {
@include container(10px, 80%, 700px, $white, $dark-grey)
}
这个
$white: #fff;
$dark-grey: #666;
@mixin container($radius, $width, $height, $bg, $color) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
width: $width;
height: $height;
background: $bg;
color: $color;
margin: 0 auto;
}
.container {
@include container(10px, 80%, 700px, $white, $dark-grey)
}
不,遗憾的是,它仍然不起作用,顺便说一句,颜色来自我之前声明的变量:(然后是其他错误-我在下面添加了输出。我只是替换了$white和$dark grey,因为它们没有显示在您的示例中-如果它们只是离开它们:)。链接:不,遗憾的是,它仍然不起作用,顺便说一下,颜色来自我之前声明的变量:(然后是其他错误-我在下面添加了输出。我只是替换了$white和$dark grey,因为它们没有显示在您的示例中-如果它们只是离开它们:)。链接:这很有效!我才意识到我的问题在哪里。非常感谢你的帮助!这管用!我才意识到我的问题在哪里。非常感谢你的帮助!