`

整理推荐的CSS属性书写顺序

css 
阅读更多

一. Mozilla 建议CSS规则

 

[html]
 
  1. <span style="font-family:Microsoft YaHei;">/* Suggested order:  
  2.  * display  
  3.  * list-style  
  4.  * position  
  5.  * float  
  6.  * clear  
  7.  * width  
  8.  * height  
  9.  * margin  
  10.  * padding  
  11.  * border  
  12.  * background  
  13.  * color  
  14.  * font  
  15.  * text-decoration  
  16.  * text-align  
  17.  * vertical-align  
  18.  * white-space  
  19.  * other text  
  20.  * content  
  21.  *  
  22.  */</span>  


详情请看http://www.mozilla.org/css/base/content.css

 

 

二.怿飞’s Blog细分为:

 

[css] 
 
  1. <span style="font-family:Microsoft YaHei;">/*显示属性*/  
  2. display  
  3. list-style  
  4. position  
  5. float  
  6. clear  
  7.   
  8. /*自身属性*/  
  9. width  
  10. height  
  11. margin  
  12. padding  
  13. border  
  14. background  
  15.   
  16. /*文本属性*/  
  17. color  
  18. font  
  19. text-decoration  
  20. vertical-align  
  21. white-space  
  22. ohter text  
  23. content</span>  

在怿飞’s Blog里有个叫做inG的补充说这还和浏览器的解析过程有关:浏览器先对DOM定位,然后解析自身属性,接着再解析内部对象。(没找到相关的英文资料,有知情者还望告知).

 


三. Andy Ford的细分

1.Display & Flow

2.Positioning

3. Dimensions

4. Margins, Padding, Borders, Outline

5. Typographic Styles

6. Backgrounds

7. Opacity, Cursors, Generated Content

 规则示例:

 

[css] 
 
  1. <span style="font-family:Microsoft YaHei;">.cl {  
  2.     display: ;  
  3.     visibility: ;  
  4.     float: ;  
  5.     clear: ;  
  6.       
  7.     position: ;  
  8.     top: ;  
  9.     right: ;  
  10.     bottom: ;  
  11.     left: ;  
  12.     z-index: ;  
  13.      
  14.     width: ;  
  15.     min-width: ;  
  16.     max-width: ;  
  17.     height: ;  
  18.     min-height: ;  
  19.     max-height: ;  
  20.     overflow: ;  
  21.   
  22.     margin: ;  
  23.     margin-top: ;  
  24.     margin-right: ;  
  25.     margin-bottom: ;  
  26.     margin-left: ;  
  27.   
  28.     padding: ;  
  29.     padding-top: ;  
  30.     padding-right: ;  
  31.     padding-bottom: ;  
  32.     padding-left: ;  
  33.   
  34.     border-width: ;  
  35.     border-top-width: ;  
  36.     border-right-width: ;  
  37.     border-bottom-width: ;  
  38.     border-left-width: ;  
  39.   
  40.     border-style: ;  
  41.     border-top-style: ;  
  42.     border-right-style: ;  
  43.     border-bottom-style: ;  
  44.     border-left-style: ;  
  45.   
  46.     border-color: ;  
  47.     border-top-color: ;  
  48.     border-right-color: ;  
  49.     border-bottom-color: ;  
  50.     border-left-color: ;  
  51.   
  52.     outline: ;  
  53.   
  54.     list-style: ;  
  55.   
  56.     table-layout: ;  
  57.     caption-side: ;  
  58.     border-collapse: ;  
  59.     border-spacing: ;  
  60.     empty-cells: ;  
  61.   
  62.     font: ;  
  63.     font-family: ;  
  64.     font-size: ;  
  65.     line-height: ;  
  66.     font-weight: ;  
  67.     text-align: ;  
  68.     text-indent: ;  
  69.     text-transform: ;  
  70.     text-decoration: ;  
  71.     letter-spacing: ;  
  72.     word-spacing: ;  
  73.     white-space: ;  
  74.     vertical-align: ;  
  75.     color: ;  
  76.   
  77.     background: ;  
  78.     background-color: ;  
  79.     background-image: ;  
  80.     background-repeat: ;  
  81.     background-position: ;  
  82.   
  83.     opacity: ;  
  84.   
  85.     cursor: ;  
  86.   
  87.     content: ;  
  88.     quotes: ;  
  89. }</span>  

详情可见http://fordinteractive.com/2009/02/order-of-the-day-css-properties/

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics