有没有办法根据某些标准对 Stylus 文件中的行进行排序,例如按字母顺序,或者按规则域,比如,所有背景的东西都一个接一个地放,然后所有定位的东西,比如 top
, right
等等?
当然,这些行应该保留在它们的父元素中。
这是一个例子:
#topbar
clearfix()
position fixed
height topBarHeight
border-bottom 1px solid rgba(#fff, 0.2)
box-sizing border-box
z-index 200
right 0
left 0
可以变成这样,按域分组:
#topbar
// mixins
clearfix()
// positioning and sizing
position fixed
z-index 200
left 0
right 0
box-sizing border-box
height topBarHeight
// border
border-bottom 1px solid rgba(#fff, 0.2)
// the rest
...
这是一种完美主义者的渴望,但让所有文件内容按某种顺序排列会很酷。
最佳答案
如果您希望在 stylus 源文件中对行进行排序,我建议您使用可编写脚本的文本编辑器(如 vim)的脚本。如果您希望优化输出,可以使用一些 postcss 插件。你可能想看看 postcss-sort和 postcss-merge-rules .如果您使用关键字“合并”,您会发现更多内容。
关于html - 排序触控笔内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29963654/