commit 25d7fc15cbedfb5210dedb8aa35f6f6765ae3aaf Author: MinJie Date: Wed Aug 24 09:49:21 2016 +0800 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..a35f62e --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# 前端规范指南 diff --git a/css/.scss-lint.yml b/css/.scss-lint.yml new file mode 100644 index 0000000..d90fa16 --- /dev/null +++ b/css/.scss-lint.yml @@ -0,0 +1,46 @@ +severity: error + +linters: + + BorderZero: + enabled: true + convention: zero + + BemDepth: + enabled: true + + DeclarationOrder: + enabled: false + + ExtendDirective: + enabled: true + + LeadingZero: + enabled: false + + NameFormat: + enabled: true + + PrivateNamingConvention: + enabled: true + prefix: _ + + PropertySortOrder: + enabled: false + + QualifyingElement: + enabled: false + + SelectorFormat: + enabled: true + convention: hyphenated_BEM + class_convention: ^(?!js-).* + class_convention_explanation: should not be written in the form js-* + + SingleLinePerProperty: + enabled: true + allow_single_line_rule_sets: false + + StringQuotes: + enabled: true + style: double_quotes diff --git a/css/README.md b/css/README.md new file mode 100644 index 0000000..c54a1c4 --- /dev/null +++ b/css/README.md @@ -0,0 +1,345 @@ +# CSS / Sass 规范指南 + +## 目录 + + 1. [术语](#terminology) + - [规则声明](#rule-declaration) + - [选择器](#selectors) + - [属性](#properties) + 1. [CSS](#css) + - [文件引用](#file-import) + - [格式](#formatting) + - [属性顺序](#order) + - [注意事项](#careful) + - [注释](#comments) + - [OOCSS 和 BEM](#oocss-and-bem) + - [ID 选择器](#id-selectors) + - [JavaScript 钩子](#javascript-hooks) + 1. [Sass](#sass) + - [语法](#syntax) + - [排序](#ordering-of-property-declarations) + - [变量](#variables) + - [Mixins](#mixins) + - [扩展指令](#extend-directive) + - [嵌套选择器](#nested-selectors) + + +## 术语 + + +### 规则声明 + +我们把一个(或一组)选择器和一组属性称之为 “规则声明”。举个例子: + +```css +.listing { + font-size: 18px; + line-height: 1.2; +} +``` + + +### 选择器 + +在规则声明中,“选择器” 负责选取 DOM 树中的元素,这些元素将被定义的属性所修饰。选择器可以匹配 HTML 元素,也可以匹配一个元素的类名、ID, 或者元素拥有的属性。以下是选择器的例子: + +```css +.my-element-class { + /* ... */ +} + +[aria-hidden] { + /* ... */ +} +``` + + +### 属性 + +最后,属性决定了规则声明里被选择的元素将得到何种样式。属性以键值对形式存在,一个规则声明可以包含一或多个属性定义。以下是属性定义的例子: + +```css +/* some selector */ { + background: #f1f1f1; + color: #333; +} +``` + + +## CSS + + +### 文件引用 + +* [建议] 使用 `link` 的方式调用外部样式 +* [强制] 不允许在 `