【问题标题】:Clear Float with SASS mixin使用 SASS mixin 清除浮点数
【发布时间】:2014-10-03 17:59:09
【问题描述】:

我遇到了一个错误

@mixin clear-fix($where) {
  &:{$where} {
    clear: both;
    content: '';
    display: block;
  }
} 

语法错误:“&:”之后的无效 CSS:预期的伪类或伪元素,在 assets/src/sass/_setup.scss 的第 2 行是“{$where} {”

我希望能够声明 afterbefore 并将其放入我想要的类中

.container {
   max-width: 1200px;
   width: 100%;

   @include clear-fix('after');
}

供参考:SASS Documentation

【问题讨论】:

  • 仔细检查你的语法。你错过了#

标签: css sass clearfix


【解决方案1】:

这是修复的代码:(您可以在此工具中测试http://sassmeister.com/

@mixin clear-fix($where) {
  &:#{$where} {
    clear: both;
    content: '';
    display: block;
  }
} 

.container {
  max-width: 1200px;
  width: 100%;

  @include clear-fix('after');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-19
    • 2020-11-23
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    相关资源
    最近更新 更多