CSS style guide

来源:互联网 发布:广电网络的未来前景 编辑:程序博客网 时间:2024/05/21 11:03

Formatting

  • Use soft tabs (2 spaces) for indentation
  • Prefer dashes over camelCasing in class names
  • Do not use ID selectors
  • When using multiple selectors in a rule declaration, give each selector its own line
  • Put a space before the opening brace { in rule declarations
  • In properties, put a space after, but not before, the : character
  • Put closing braces } of rule declarations on a new line
  • Put blank lines between rule declarations

Comment

  • Prefer line comments (// in Sass-land) to block comments.
  • Prefer comments on their own line. Avoid end-of-line comments.
  • Write detailed comments for code that isn’t self-documenting:
    • Uses of z-index
    • Compatibility or browser-specific hacks

Order

  1. Positioning properties
  2. Display properties
  3. Box properties
  4. Content properties (including background)
  5. Pseudo properties
原创粉丝点击