Sass: Dealing with the IE 4095 selectors per stylesheet restriction

北城以北 提交于 2019-12-03 01:28:11
crispy

Mixins are usable across multiple files. However, it is logically not possible that @extend may work with multiple files. It is the purpose of this directive to result in a single rule (which should not be duplicated across multiple files). Therefore, I cannot split up files.

Thus, I implemented a splitter: https://gist.github.com/1131536

After these two commits have found their way into Sass and Compass, you can use the following hook in your Rails config/compass.rb in order to automatically create the additional stylesheets for IE:

on_stylesheet_saved do |filename|
  if File.exists?(filename)
    CssSplitter.split(filename)
  end
end

Update:

The CssSplitter mentionend above has been release as a gem: https://github.com/zweilove/css_splitter

If you can't reduce the number of selectors, there is no choice other than to split the CSS file.

Your proposed solution for doing so already sounds optimal, if a little complicated to implement.

An easy way to do it is http://blesscss.com/. Simply :

  • install node.js
  • Execute npm install bless -g
  • blessc source.css output.css
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!