• CSS规范


    空格规范

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

    示例:

    .selector {
    }

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

    font-size: 12px;

    选择器规范

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

    示例:

    /* good */
    .post,
    .page,
    .comment {
        line-height: 1.5;
    }
    
    
    /* bad */
    .post, .page, .comment {
        line-height: 1.5;
    }

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

    示例:

    /* good */
    #username input {}
    .comment .avatar {}
    
    /* bad */
    .page .header .login  input {}
    .comment div * {}

    属性规范

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

    示例:

    /* good */
    .selector {
        margin: 0;
        padding: 0;
    }
    
    /* bad */
    .selector { margin: 0; padding: 0; }

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

    示例:

    /* good */
    .selector {
        margin: 0;
    }
    
    /* bad */
    .selector {
        margin: 0
    }

    CSS属性书写顺序

    建议遵循以下顺序:

    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;
         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;
    }
  • 相关阅读:
    UVALive 8519 Arrangement for Contests 2017西安区域赛H 贪心+线段树优化
    UVALive 8513 lovers 2017 西安区域赛 B 贪心+multiset
    JAVA导出EXCEL——POI(转)
    Oracle导入导出——windows命令行形式
    miniUI ExcelExport导出JAVA实现
    JSONObject遍历获取键值
    wrong number of arguments
    JAVA批量修改文件名
    miniUI DataGrid编辑后事件代码示例
    oracle10g没有行列转换函数的替代方法(转)
  • 原文地址:https://www.cnblogs.com/featherwit/p/13282593.html
Copyright © 2020-2023  润新知