問題描述
我搞砸了我的 css,不知何故我有很多重復(fù)的規(guī)則,而我的 1800 行 css 文件現(xiàn)在有 3000 多行..
I messed up my css and somehow i have a lot of the duplicate rules and my 1800 something lines css file is now of 3000+ lines..
是否有任何方法/工具可以將我的 css 文件作為輸入并檢查所有重復(fù)的規(guī)則?并可能生成一個 css 刪除那些冗余?
Is there any way/tool that would take my css file as input and check for all the duplicate rules? and possibly generate a css removing those redundancies?
推薦答案
安裝Node JShttps://nodejs.org/en/download/
如果您已經(jīng)安裝了 node js,或者在安裝打開 node 命令提示符窗口后通過在 start 中鍵入 node(在 windows 機器上).
if you have already node js installed or after installing open node command prompt window by typing node( on windows machine) in start.
鍵入以下命令以安裝 css purge 工具
Type following command to install css purge tool
npm install css-purge -g
npm install css-purge -g
工具安裝后,
打開節(jié)點命令提示符窗口所在的文件夾并粘貼混亂的 css 文件,然后在節(jié)點命令提示符窗口中鍵入以下命令
Open the folder where node command prompt window is open and paste messed up css file there and then type following command in node cmd prompt window
css-purge -i style.css -o style_purged.css
css-purge -i style.css -o style_purged.css
其中 style.css 是混亂的 css 文件的名稱,上面的命令將創(chuàng)建一個名為 style_purged.css 的新 css 文件,其中不包含重復(fù)的 css 規(guī)則.
where style.css is the name of messed up css file, the above command will create a new css file with name style_purged.css which does not contain duplicate css rules.
但要小心,它也會刪除您的評論.https://www.npmjs.com/package/css-purge
But be careful, it will also remove the comments you have. https://www.npmjs.com/package/css-purge
這篇關(guān)于如何檢查重復(fù)的 CSS 規(guī)則?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!