4-14 CSS书写规范 慢补充

慢慢施工....

 

 

从一开始就养成良好的书写规范。是你专业的开始。

空格规范

【强制】  选择器 与 { 之间必须包含空格

【强制】  属性名 与之后的:之间不允许包含空格,  :与属性值之间必须包含空格。

选择器规范

【强制】  并集选择器,每个选择器声明必须独占一行。 

【强制】  选择器的结尾 } 与标签垂直对齐。

【建议】 一般情况下,选择器的嵌套层级应不大于3级,位置靠后的限定条件应尽可能精确。   

属性规范

【强制】  属性定义必须另起一行。

【强制】  属性定义后必须以分号结尾。

属性书写顺序

建议遵循以下顺序:

  1. 布局定位属性:display / position / float / clear / visibility /overflow (建议 display 第一个写,毕竟关系到模式)
  2. 自身属性:width / height /margin /padding / border / background
  3. 文本属性:color / font / text-decoration / text-align / vertical-align / white-space / break-word
  4. 其他属性(CSS3):content / cursor / border-radius / box-shadow / text-shadow /background: linear-gradient ...
.jdc {
     display: block;
     position: relative;
     float: left;
     width: 100px;
     height: 100px;
     margin: 0 10px;
     padding: 20px 0;
     font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
     color: #333;
     background: rgba(0, 0, 0, .5);
     -webkit-border-radius: 10px;
     -moz-border-radius: 10px;
     -o-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px; }

 

posted @ 2020-12-22 05:02  Nelson-Yen  阅读(54)  评论(0)    收藏  举报