kisshere
V2EX  ›  问与答

有没有将 CSS 去除冗余代码和合并相同 div 属性的工具?

  •  
  •   kisshere · Nov 8, 2014 · 4961 views
    This topic created in 4298 days ago, the information mentioned may be changed or developed.
    目前修改一套CMS前端,因为这个CMS的css文件数量繁多,改起来较为麻烦,因此我单独写了一个another.css来覆盖原CMS的css,于是就出现了很多重复和待合并的css属性:
    系统global.css:

    #main_div{width:960px;background:#fff}
    #login{width:400px;height:300px}
    另外这个#login还分散到了很多其他css文件中:
    系统account.css:
    #login{position:absolute;left:50%:top:50%;margin-left:-200px;margin-top:-150px}
    --------------------------------------------------------------------------------------------------------------
    而我写的another.css直接覆盖掉了原来的global.css和account.css :

    #login{width:100%;height:100%;position:fixed;left:0;top:0}
    #main_div{background:#eaeaea}

    那么问题来了,我想最终通过一个工具把这些冗余和待合并的css属性全部合并为一个文件,这样能极大减少文件大小的体积,而且也便于维护,求V2ER推荐个工具
    2 replies    2014-11-08 11:43:10 +08:00
    fanpenghua
        1
    fanpenghua  
       Nov 8, 2014
    SASS LESS 重构吧
    emric
        2
    emric  
       Nov 8, 2014   ❤️ 1
    可以用 uncss,不过局限性很大.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2899 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 03:59 · PVG 11:59 · LAX 20:59 · JFK 23:59
    ♥ Do have faith in what you're doing.