美文网首页
四、sass编码输出格式

四、sass编码输出格式

作者: 柳暗花明又一匪 | 来源:发表于2018-01-25 15:29 被阅读0次
    1.:expanded标准格式

    Expanded 输出更像是手写的样式,选择器、属性等各占用一行,属性根据选择器缩进,而选择器不做任何缩进。

    sass --watch style.style.css --style expanded//标准格式
    //------------------------------------------------------------------------
    #main {
      color: #fff;
      background-color: #000;
    }
    #main p {
      width: 10em;
    }
    
    .huge {
      font-size: 10em;
      font-weight: bold;
      text-decoration: underline;
    }
    
    2.:nested嵌套模式

    Nested (嵌套)样式是 Sass 默认的输出格式,能够清晰反映 CSS 与 HTML 的结构关系。选择器与属性等单独占用一行,缩进量与 Sass 文件中一致,每行的缩进量反映了其在嵌套规则内的层数。当阅读大型 CSS 文件时,这种样式可以很容易地分析文件的主要结构。

    sass --watch style.style.css --style nested//嵌套模式
    //------------------------------------------------------------------------
    #main {
      color: #fff;
      background-color: #000; }
      #main p {
        width: 10em; }
    
    .huge {
      font-size: 10em;
      font-weight: bold;
      text-decoration: underline; }
    
    3.:compact单行压缩

    Compact 输出方式比起上面两种占用的空间更少,每条 CSS 规则只占一行,包含其下的所有属性。嵌套过的选择器在输出时没有空行,不嵌套的选择器会输出空白行作为分隔符。

    sass --watch style.style.css --style compact//单行压缩
    //------------------------------------------------------------------------
    #main { color: #fff; background-color: #000; }
    #main p { width: 10em; }
    
    .huge { font-size: 10em; font-weight: bold; text-decoration: underline; }
    
    4.:compressed压缩格式

    Compressed 输出方式删除所有无意义的空格、空白行、以及注释,力求将文件体积压缩到最小,同时也会做出其他调整,比如会自动替换占用空间最小的颜色表达方式。

    sass --watch style.style.css --style compressed// 压缩格式
    //------------------------------------------------------------------------
    #main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}
    

    相关文章

      网友评论

          本文标题:四、sass编码输出格式

          本文链接:https://www.haomeiwen.com/subject/fmxvaxtx.html