首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >凹槽改变属性的顺序

凹槽改变属性的顺序
EN

Stack Overflow用户
提问于 2015-07-11 11:37:37
回答 1查看 223关注 0票数 1

我使用node.js,咕噜和休息将我的*.less文件编译成*.css文件。

代码语言:javascript
复制
 It's my Gruntfile.js file
代码语言:javascript
复制
 module.exports = function(grunt) {

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    recess: {
        dist: {
            options: {
                compile: true
            },
            files: {
                'css/style.css': 'less/style.less'
            }
        }
    },
    watch: {
        recess: {
            files: ['less/*.less'],
            tasks: ['recess'],
            options: {
                spawn: false,
            },
        }
    }
});

grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['recess', 'watch']);

};

但是现在我需要在输出*.css文件中更改属性的顺序,如

代码语言:javascript
复制
.class {
  margin: 0;
  padding: 0;

  width: auto;
  min-width: 0;
  max-width: 0;
  height: auto;
  min-height: 0;
  max-height: 0;

  display: block;
  visibility: hidden;
  overflow: hidden;
  float: none;

  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  text-align: left;
  text-decoration: none;
  text-indent: 1;
  text-transform: uppercase;
  letter-spacing: 1;
  vertical-align: top;
  line-height: 1;
  white-space: normal;
  word-spacing: normal;

  font: 1em sans-serif;
  font-family: Arial, sans-serif;
  font-size: 1em;
  font-weight: normal;
  font-style: normal;
  font-variant: normal;

  opacity: 1;
  color: red;
  border: 1px solid red;
  background: #fff url(../i/bg.png) no-repeat 0 0;  

  z-index: 0
  cursor: default;

}

我发现了strict-property-order.js https://github.com/twitter/recess/blob/master/lib/lint/strict-property-order.js#L36,我想它可以帮助我,但我不知道如何使用它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-28 10:48:06

若要更改希望输出属性的顺序,请在order中编辑strict-property-order.js数组。

例如:

order = [ 'position' , 'top' , 'right' , 'bottom' , 'left' ]

可改为:

order = [ 'position' , 'right' , 'top' , 'bottom' , 'left' ]

但是,不存在简单的config.json或类似的东西,您可以将其放在项目的根目录中并进行编辑,而无需处理节点模块,原因是休息是按属性排序的方式确定的。

如果您想要更多的自由,还有其他选项(例如各种.less指针和css-梳理之类的东西,它们可以在编译后运行)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31356773

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档