zoukankan      html  css  js  c++  java
  • CSS书写顺序提高可读性

    属性书写顺序

    [建议] 同一 rule set 下的属性在书写时,应按功能进行分组,并以 Formatting Model(布局方式、位置) > Box Model(尺寸) > Typographic(文本相关) > Visual(视觉效果) 的顺序书写,以提高代码的可读性。

    解释:

    • Formatting Model 相关属性包括:position / top / right / bottom / left / float / display / overflow 等
    • Box Model 相关属性包括:border / margin / padding / width / height 等
    • Typographic 相关属性包括:font / line-height / text-align / word-wrap 等
    • Visual 相关属性包括:background / color / transition / list-style 等

    另外,如果包含 content 属性,应放在最前面。

    示例:

    .sidebar {
        /* formatting model: positioning schemes / offsets / z-indexes / display / ...  */
        position: absolute;
        top: 50px;
        left: 0;
        overflow-x: hidden;
    
        /* box model: sizes / margins / paddings / borders / ...  */
         200px;
        padding: 5px;
        border: 1px solid #ddd;
    
        /* typographic: font / aligns / text styles / ... */
        font-size: 14px;
        line-height: 20px;
    
        /* visual: colors / shadows / gradients / ... */
        background: #f5f5f5;
        color: #333;
        -webkit-transition: color 1s;
           -moz-transition: color 1s;
                transition: color 1s;
    }
  • 相关阅读:
    Hexo博客搭建教程
    windows7如何查看端口被占用
    openshift rhc
    .net面试题精选
    Java垃圾回收机制
    Maven 入门篇(下)
    Maven 入门篇 ( 上 )
    OPENSHIFT MYSQL使用Navicat远程连接
    ci配置smarty手记
    solr多核配置
  • 原文地址:https://www.cnblogs.com/qjuly/p/8985215.html
Copyright © 2011-2022 走看看