热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

SASSmixin中的条件抛出错误

如何解决《SASSmixin中的条件抛出错误》经验,为你挑选了1个好方法。

我正在尝试使用条件创建一个mixin但我在编译时遇到错误.生成的错误是:

Error: Properties are only allowed within rules, directives, mixin includes, or other properties.

这是我正在使用的代码:

@mixin mypadder ($topBottomBoth: myDefaultOption, $topUnits: 0, $bottomUnits: 0) {
    @if $topBottomBoth == tp {
        padding-top: 1em;
        }
    @else if $topBottomBoth == bt {
        padding-bottom: 1em;
        }
    @else {
        padding-top: 1em;
        padding-bottom: 1em;
        }
    }

我还尝试将$ topBottomBoth参数的值放在引号中,首先只是它出现在参数(mixin的第一行)中的位置,然后在条件测试中另外在该变量/参数的值周围加上引号.在每种情况下,我都会得到同样的错误.看了很多条件混合的例子后,我仍然无法看到我的语法错误.



1> cimmanon..:

你的mixin没什么问题,你只是说错了.Sass知道在选择器之外不允许使用CSS属性.

不正确:

@include mypadder;

正确:

.foo {
    @include mypadder;
}


推荐阅读
author-avatar
书友50398197
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有