Sass: Dealing with the IE 4095 selectors per stylesheet restriction

前端 未结 3 1564
执念已碎
执念已碎 2021-02-04 17:29

Note: This question refers to a Rails project with Sass & Compass. Using the Rails Asset Pipeline? Then have a look at this question.

We are developing a bi

相关标签:
3条回答
  • 2021-02-04 17:50

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

    • install node.js
    • Execute npm install bless -g
    • blessc source.css output.css
    0 讨论(0)
  • 2021-02-04 17:54

    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

    0 讨论(0)
  • 2021-02-04 17:58

    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.

    0 讨论(0)
提交回复
热议问题