Online CSS compress which doesn't remove IE hacks

点点圈 提交于 2020-01-14 01:54:12

问题


Are there are CSS compressors online which do not remove any of the CSS browser hacks.

E.g: Using: cleancss.com it makes no difference which options I set it will always remove the *display for IE display inline-block hack.

a {
    border-radius:5px
    display: inline-block;
    *display: inline;
    zoom: 1;
    text-shadow: 0 2px 3px rgba(0,0,0,0.4);
    -moz-border-radius:5px;-webkit-border-radius:5px;
}

回答1:


CSS Compressor and Clean CSS usually work for me, although I prefer to use a different stylesheet for all previous versions of internet explorer. It is usually better to keep previous browser supporting css seprately. Or keep hacks in a seprate file and appened it to the compressed css.

In your case, however, the compressors do remove *

I do not know any online compressors which preserve the hacks, however, I can offer workarounds.

A solution would be to use hacks on selector rather than on attribute. Here are a couple of examples :

* html #uno  { color: red } /*IE6 and below*/
*+html #dos { color: red }  /*IE7*/

Check here about the other hacks available : http://paulirish.com/2009/browser-specific-css-hacks/

If that does not work for you another workaround, might be a little tiresome, but before compression, add some unique value before a hack like

#uno {#HACK#display:inline;}

and then after compression using a text editor replace all #HACK# with *




回答2:


This one worked for me using your test code - http://www.cssdrive.com/index.php/main/csscompressor

As did - http://iceyboard.no-ip.org/projects/css_compressor, http://www.refresh-sf.com/yui/ and http://tools.arantius.com/css-compressor

It might be worth googling your question before you actually post it on here. I did a search for "css compressor", opened the first 6 results and found those four all compressed your code without removing any of the hacks.

stackoverflow isn't supposed to be used to ask something you're too lazy to search for yourself.




回答3:


Any of these four five online minifiers do their work in way you satisfied

  • http://www.creativyst.com/Prod/3/
  • http://www.cssdrive.com/compressor/compress.php
  • http://iceyboard.no-ip.org/projects/css_compressor
  • http://tools.arantius.com/css-compressor
  • http://www.cssdrive.com/index.php/main/csscompressor/ (thanx to @JFK)

And also a smart tool (developed and used by russian Yandex) has both online and back-end versions

  • http://css.github.com/csso/csso.html



回答4:


Try Devilo.us, which is based on CSSTidy. You can select exactly how much it compresses and how.




回答5:


http://css.github.com/csso/csso.html — this one worked for me. It is not only trim unused symbols, but also remove duplicate rules, and group selector if in help's make size smaller.

It is online version of following tool: https://github.com/css/csso



来源:https://stackoverflow.com/questions/10852013/online-css-compress-which-doesnt-remove-ie-hacks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!