Приводим CSS стили к единому и красивому формату

Admin CSS, Mac OS, Software

Установка CSScomb, дополнения для Sublime Text 3, которое позволяет привести CSS код к единому стилю.

Устанавливаем CSSComb для Sublime через Package Control: Insall Package.

Страница на GitHab:
https://github.com/csscomb/sublime-csscomb

По умолчанию CSSComb группирует свойства CCS по типу:

Но например, линтеру SublimeLinter-csslint не нравится всё кроме алфавитного порядка CSS. Да я и сам пришел к выводу, что это намного удобнее.

Так что вот мои настройки CSSComb, которые упорядочивают CSS в алфавитном порядке:

{
    // If plugin has trouble finding Node.js, replace this string with path
    // to your `node` bin
    "node-path" : ":/usr/local/bin",

    // Full list of supported options and acceptable values can be found here:
    // https://github.com/csscomb/csscomb.js/blob/master/doc/options.md
    "config": {

        // Whether to add a semicolon after the last value/mixin.
        "always-semicolon": false,

        // Set indent for code inside blocks, including media queries and nested rules.
        "block-indent": "    ",

        // Unify case of hexadecimal colors.
        "color-case": "lower",

        // Whether to expand hexadecimal colors or use shorthands.
        "color-shorthand": false,

        // Unify case of element selectors.
        "element-case": "lower",

        // Add/remove line break at EOF.
        "eof-newline": false,

        // Add/remove leading zero in dimensions.
        "leading-zero": false,

        // Unify quotes style.
        "quotes": "single",

        // Remove all rulesets that contain nothing but spaces.
        "remove-empty-rulesets": false,

        // Set space after `:` in declarations.
        "space-after-colon": " ",

        // Set space after combinator (for example, in selectors like `p > a`).
        "space-after-combinator": " ",

        // Set space after `{`.
        "space-after-opening-brace": "\n",

        // Set space after selector delimiter.
        // Новая строчка перед каждым элементом, можно сделать в строку
        "space-after-selector-delimiter": "\n",

        // Set space before `}`.
        "space-before-closing-brace": "\n",

        // Set space before `:` in declarations.
        "space-before-colon": "",

        // Set space before combinator (for example, in selectors like `p > a`).
        "space-before-combinator": " ",

        // Set space before `{`.
        // Устанавливает пробел между элементом и скобкой
        "space-before-opening-brace": " ",

        // Set space before selector delimiter.
        "space-before-selector-delimiter": "",

        // Set space between declarations (i.e. `color: tomato`).
        "space-between-declarations": "\n",

        // Whether to trim trailing spaces.
        "strip-spaces": false,

        // Whether to remove units in zero-valued dimensions.
        "unitless-zero": false,

        // Whether to align prefixes in properties and values.
        "vendor-prefix-align": false,

        // Sort properties in particular order.
        "sort-order": [
                "-moz-animation",
                "-moz-animation-delay",
                "-moz-animation-direction",
                "-moz-animation-duration",
                "-moz-animation-iteration-count",
                "-moz-animation-name",
                "-moz-animation-play-state",
                "-moz-animation-timing-function",
                "-moz-background-clip",
                "-moz-background-size",
                "-moz-border-image",
                "-moz-border-image-outset",
                "-moz-border-image-repeat",
                "-moz-border-image-slice",
                "-moz-border-image-source",
                "-moz-border-image-width",
                "-moz-border-radius",
                "-moz-border-radius-bottomleft",
                "-moz-border-radius-bottomright",
                "-moz-border-radius-topleft",
                "-moz-border-radius-topright",
                "-moz-box-shadow",
                "-moz-box-sizing",
                "-moz-hyphens",
                "-moz-tab-size",
                "-moz-text-align-last",
                "-moz-transform",
                "-moz-transform-origin",
                "-moz-transition",
                "-moz-transition-delay",
                "-moz-transition-duration",
                "-moz-transition-property",
                "-moz-transition-timing-function",
                "-moz-user-select",
                "-ms-animation",
                "-ms-animation-delay",
                "-ms-animation-direction",
                "-ms-animation-duration",
                "-ms-animation-iteration-count",
                "-ms-animation-name",
                "-ms-animation-play-state",
                "-ms-animation-timing-function",
                "-ms-background-position-x",
                "-ms-background-position-y",
                "-ms-filter:\'progid:DXImageTransform.Microsoft.Alpha",
                "-ms-filter:\'progid:DXImageTransform.Microsoft.gradient",
                "-ms-interpolation-mode",
                "-ms-overflow-x",
                "-ms-overflow-y",
                "-ms-text-align-last",
                "-ms-text-justify",
                "-ms-text-overflow",
                "-ms-transform",
                "-ms-transform-origin",
                "-ms-transition",
                "-ms-transition-delay",
                "-ms-transition-duration",
                "-ms-transition-property",
                "-ms-transition-timing-function",
                "-ms-user-select",
                "-ms-word-break",
                "-ms-word-wrap",
                "-ms-writing-mode",
                "-o-animation",
                "-o-animation-delay",
                "-o-animation-direction",
                "-o-animation-duration",
                "-o-animation-iteration-count",
                "-o-animation-name",
                "-o-animation-play-state",
                "-o-animation-timing-function",
                "-o-background-size",
                "-o-border-image",
                "-o-border-image-outset",
                "-o-border-image-repeat",
                "-o-border-image-slice",
                "-o-border-image-source",
                "-o-border-image-width",
                "-o-tab-size",
                "-o-transform",
                "-o-transform-origin",
                "-o-transition",
                "-o-transition-delay",
                "-o-transition-duration",
                "-o-transition-property",
                "-o-transition-timing-function",
                "-webkit-animation",
                "-webkit-animation-delay",
                "-webkit-animation-direction",
                "-webkit-animation-duration",
                "-webkit-animation-iteration-count",
                "-webkit-animation-name",
                "-webkit-animation-play-state",
                "-webkit-animation-timing-function",
                "-webkit-background-clip",
                "-webkit-background-size",
                "-webkit-border-bottom-left-radius",
                "-webkit-border-bottom-right-radius",
                "-webkit-border-image",
                "-webkit-border-image-outset",
                "-webkit-border-image-repeat",
                "-webkit-border-image-slice",
                "-webkit-border-image-source",
                "-webkit-border-image-width",
                "-webkit-border-radius",
                "-webkit-border-top-left-radius",
                "-webkit-border-top-right-radius",
                "-webkit-box-shadow",
                "-webkit-box-sizing",
                "-webkit-hyphens",
                "-webkit-text-align-last",
                "-webkit-transform",
                "-webkit-transform-origin",
                "-webkit-transition",
                "-webkit-transition-delay",
                "-webkit-transition-duration",
                "-webkit-transition-property",
                "-webkit-transition-timing-function",
                "-webkit-user-select",
                "animation",
                "animation-delay",
                "animation-direction",
                "animation-duration",
                "animation-iteration-count",
                "animation-name",
                "animation-play-state",
                "animation-timing-function",
                "background",
                "background-attachment",
                "background-clip",
                "background-color",
                "background-image",
                "background-origin",
                "background-position",
                "background-position-x",
                "background-position-y",
                "background-repeat",
                "background-size",
                "border",
                "border-bottom",
                "border-bottom-color",
                "border-bottom-left-radius",
                "border-bottom-right-radius",
                "border-bottom-style",
                "border-bottom-width",
                "border-collapse",
                "border-color",
                "border-image",
                "border-image-outset",
                "border-image-repeat",
                "border-image-slice",
                "border-image-source",
                "border-image-width",
                "border-left",
                "border-left-color",
                "border-left-style",
                "border-left-width",
                "border-radius",
                "border-right",
                "border-right-color",
                "border-right-style",
                "border-right-width",
                "border-spacing",
                "border-style",
                "border-top",
                "border-top-color",
                "border-top-left-radius",
                "border-top-right-radius",
                "border-top-style",
                "border-top-width",
                "border-width",
                "bottom",
                "box-decoration-break",
                "box-shadow",
                "box-sizing",
                "caption-side",
                "clear",
                "clip",
                "color",
                "content",
                "counter-increment",
                "counter-reset",
                "cursor",
                "display",
                "empty-cells",
                "filter:progid:DXImageTransform.Microsoft.Alpha(Opacity",
                "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader",
                "filter:progid:DXImageTransform.Microsoft.gradient",
                "flex-align",
                "flex-direction",
                "flex-order",
                "flex-pack",
                "float",
                "font",
                "font-effect",
                "font-emphasize",
                "font-emphasize-position",
                "font-emphasize-style",
                "font-family",
                "font-size",
                "font-size-adjust",
                "font-smooth",
                "font-stretch",
                "font-style",
                "font-variant",
                "font-weight",
                "height",
                "hyphens",
                "left",
                "letter-spacing",
                "line-height",
                "list-style",
                "list-style-image",
                "list-style-position",
                "list-style-type",
                "margin",
                "margin-bottom",
                "margin-left",
                "margin-right",
                "margin-top",
                "max-height",
                "max-width",
                "min-height",
                "min-width",
                "nav-down",
                "nav-index",
                "nav-left",
                "nav-right",
                "nav-up",
                "opacity",
                "outline",
                "outline-color",
                "outline-offset",
                "outline-style",
                "outline-width",
                "overflow",
                "overflow-x",
                "overflow-y",
                "padding",
                "padding-bottom",
                "padding-left",
                "padding-right",
                "padding-top",
                "pointer-events",
                "position",
                "quotes",
                "resize",
                "right",
                "tab-size",
                "table-layout",
                "text-align",
                "text-align-last",
                "text-decoration",
                "text-emphasis",
                "text-emphasis-color",
                "text-emphasis-position",
                "text-emphasis-style",
                "text-indent",
                "text-justify",
                "text-outline",
                "text-overflow",
                "text-overflow-ellipsis",
                "text-overflow-mode",
                "text-shadow",
                "text-transform",
                "text-wrap",
                "top",
                "transform",
                "transform-origin",
                "transition",
                "transition-delay",
                "transition-duration",
                "transition-property",
                "transition-timing-function",
                "user-select",
                "vertical-align",
                "visibility",
                "white-space",
                "width",
                "word-break",
                "word-spacing",
                "word-wrap",
                "z-index",
                "zoom"
            ]
    }
}

Результат алфавитного упорядочивания CSS стилей с помощью CSS Combo:

Метки:

У сайта нет цели самоокупаться, поэтому на сайте нет рекламы. Но если вам пригодилась информация, можете лайкнуть страницу, оставить комментарий или отправить мне подарок на чашечку кофе.

Комментарии к статье “Приводим CSS стили к единому и красивому формату” (3)

    • Admin
      Автор записи
      16.11.2017 в 02:33

      Не думал в этом направлении. Может быть после элемента поставить «\n» или отбить пустую строчку после нужного свойства – в кавычках оставить пустое значение:

      "-moz-animation-delay",
      "-moz-animation-direction",
      " ",
      "-moz-animation-duration",
      

Добавить комментарий для Admin Отменить ответ

Напишите свой комментарий, если вам есть что добавить/поправить/спросить по теме текущей статьи:
"Приводим CSS стили к единому и красивому формату"