【问题标题】:gulp-sass new line for multi selector多选择器的 gulp-sass 新行
【发布时间】:2016-10-13 17:03:25
【问题描述】:

我要建造

.btn-default {
    color: #ccc;

    &:hover,
    &:focus {
        color: #ddd;
    }
}

进入

.btn-default {
    color: #ccc;
}

.btn-default:hover, 
.btn-default:focus {
    color: #ddd;
}

但是相反,它比较成

.btn-default {
    color: #ccc;
}

.btn-default:hover, .btn-default:focus {
    color: #ddd;
}

另一方面,如果没有 &,它可以正常工作

a,
.btn {
    color: #ccc;
}

进入

a,
.btn {
    color: #ccc;
}

那么,我应该如何将& 构建成多行?

我使用 gulp-sass。选项可用here

【问题讨论】:

  • 即使是一个带有& 的选择器和其他没有工作的选择器。所以看起来只有当 Sass 编译器本身都在一行中输出它时

标签: css sass gulp gulp-sass node-sass


【解决方案1】:

Sass 只提供 4 种编译输出样式:
(https://github.com/sass/node-sass#outputstyle)

:nested :expanded :compact :compressed

没有办法得到你想要的结果,但你可以使用类似:https://github.com/csscomb/csscomb.js 来格式化它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-02
    • 2013-09-04
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-04
    • 1970-01-01
    相关资源
    最近更新 更多