开发者

How to compress CSS

I've looked at half a dozen CSS opt开发者_运维问答imisers out there. What I'm looking for is one that will turn:

background-image: url(../images/background.png);
background-repeat: repeat-x;
background-color: #c0c0c0;

Into the single background property:

background: #c0c0c0 url(../images/background.png) repeat-x;

How can I do this? Do I have to do it by hand?


Try http://www.cssoptimiser.com/

Input:

body {
    background-image: url(../images/background.png);
    background-repeat: repeat-x;
    background-color: #c0c0c0;
}

(I ticked "Do not remove line breaks")

Output:

body {
    background:#c0c0c0 url(../images/background.png) repeat-x
}

Note that it also optimised away the space - you asked for background:<space>#... :)

There may be other/better tools which can do this, but that site does fulfill your wish.


Make sure you also have gzip enabled on your server (or some other form of compression for text files).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜