选择器命名

属性定义

每个属性一行, 禁止一个选择器定义成一行; 属性大括号前空格, 起始大括号和选择器名放在一行, 多个选择器一起定义时每个选择器一行.

.selector {
  height:400px;
  width:400px;
}

.site-nav{
  position:fixed;
  top:0;
  left:0;
  right:0;
  width:100%;
}

属性顺序

以类型分组 css 属性, 以下面顺序定义 css 属性

.selector {
  /* 位置属性 */
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;

  /* 显示&盒模型 */
  display: inline-block;
  overflow: hidden;
  box-sizing: border-box;
  width: 100px;
  height: 100px;
  padding: 10px;
  border: 10px solid #333;
  margin: 10px;

  /* 颜色 */
  background: #000;
  color: #fff
  
  /* 字体 */
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.4;
  text-align: right;

  /* 其他 */
  cursor: pointer;
}
blog comments powered by Disqus