【问题标题】:scss custom mixin overwrites change value does not replace, but adds itscss自定义mixin覆盖更改值不替换,但添加它
【发布时间】:2020-08-25 22:35:46
【问题描述】:

我想将边框半径值 0 覆盖为 4px

不替换,而是添加。我做错了什么?

@import:theme.scss:

.uk-button {
    border-radius: 0;
    @if(mixin-exists(hook-button)) { @include hook-button(); }
}

custom.scss:

// Custom mixin overwrites
// that's correct?
@mixin hook-button() {
    border-radius: 4px;
}

意外结果:

.uk-button {
    border-radius: 0; 
    border-radius: 4px;
}

预期结果:

.uk-button {
    border-radius: 4px;
}

【问题讨论】:

    标签: css sass scss-mixins


    【解决方案1】:

    @include,正如它所说,仅添加/包含特定规则,但不会替换它们。

    主题 SCSS 应如下所示:

    .uk-button {
        @if(mixin-exists(hook-button)) { @include hook-button(); }
        @else { border-radius: 0; }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-10-17
      • 2015-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-31
      • 2014-02-17
      • 1970-01-01
      • 2017-04-14
      相关资源
      最近更新 更多