css书写规范

时间:2022-06-18
本文章向大家介绍css书写规范,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
  • 属性的书写顺要有一定的规律。
    1. Display & Flow
    2. Positioning
    3. Dimensions
    4. Margins, Padding, Borders, Outline
    5. Typographic Styles
    6. Backgrounds
    7. Opacity, Cursors, Generated Content

 从上到下的书写顺序示例:

 .foobar {
    display: ;
    visibility: ;
    float: ;
    clear: ;
 
    position: ;
    top: ;
    right: ;
    bottom: ;
    left: ;
    z-index: ;
 
    width: ;
    min-width: ;
    max-width: ;
    height: ;
    min-height: ;
    max-height: ;
    overflow: ;
 
    margin: ;
    margin-top: ;
    margin-right: ;
    margin-bottom: ;
    margin-left: ;
 
    padding: ;
    padding-top: ;
    padding-right: ;
    padding-bottom: ;
    padding-left: ;
 
    border: ;
    border-top: ;
    border-right: ;
    border-bottom: ;
    border-left: ;
 
    border-width: ;
    border-top-width: ;
    border-right-width: ;
    border-bottom-width: ;
    border-left-width: ;
 
    border-style: ;
    border-top-style: ;
    border-right-style: ;
    border-bottom-style: ;
    border-left-style: ;
 
    border-color: ;
    border-top-color: ;
    border-right-color: ;
    border-bottom-color: ;
    border-left-color: ;
 
    outline: ;
 
    list-style: ;
 
    table-layout: ;
    caption-side: ;
    border-collapse: ;
    border-spacing: ;
    empty-cells: ;
 
    font: ;
    font-family: ;
    font-size: ;
    line-height: ;
    font-weight: ;
    text-align: ;
    text-indent: ;
    text-transform: ;
    text-decoration: ;
    letter-spacing: ;
    word-spacing: ;
    white-space: ;
    vertical-align: ;
    color: ;
 
    background: ;
    background-color: ;
    background-image: ;
    background-repeat: ;
    background-position: ;
 
    opacity: ;
 
    cursor: ;
 
    content: ;
 
    quotes: ;
 
  }