如何使用 scss @include
How to use scss @include
我有一个 SCSS 文件,我想 @include transition(all, 0.5s);
但是 scss 给了
错误信息:
Scss compiler Error: no mixin named transition
这是我的 SCSS
:
a {
float: left;
line-height: 70px;
text-decoration: none;
color: white;
@include transition(all, 0.3s);
&:hover {
background-color: #444;
@include transition(all, .5s);
}
}
@mixin reset-list {
margin: 0;
padding: 0;
list-style: none;
}
然后使用它
@include reset-list
https://sass-lang.com/documentation/at-rules/mixin
但是我看到你正试图在你的 mixin 中使用参数
@mixin bordered($color, $width: 2px) {
color: #77C1EF;
border: $width solid black;
width: 450px;
}
.style {
@include bordered($color:#77C1EF, $width: 2px);
}
简而言之:
在包含它之前声明你的mixin。你的错误说混音不存在
@mixin transition($includes, $length) {
transition: $includes $length;
}
.style {
@include transition($includes: all, $length: .2s);
}
我有一个 SCSS 文件,我想 @include transition(all, 0.5s);
但是 scss 给了
错误信息:
Scss compiler Error: no mixin named transition
这是我的 SCSS
:
a {
float: left;
line-height: 70px;
text-decoration: none;
color: white;
@include transition(all, 0.3s);
&:hover {
background-color: #444;
@include transition(all, .5s);
}
}
@mixin reset-list {
margin: 0;
padding: 0;
list-style: none;
}
然后使用它
@include reset-list
https://sass-lang.com/documentation/at-rules/mixin
但是我看到你正试图在你的 mixin 中使用参数
@mixin bordered($color, $width: 2px) {
color: #77C1EF;
border: $width solid black;
width: 450px;
}
.style {
@include bordered($color:#77C1EF, $width: 2px);
}
简而言之: 在包含它之前声明你的mixin。你的错误说混音不存在
@mixin transition($includes, $length) {
transition: $includes $length;
}
.style {
@include transition($includes: all, $length: .2s);
}