2

I just worked out, by trial-and-error, that IE 7 has an upper limit of 32 stylesheet includes (i.e. tags).

I'm working on the front-end of a very large website, in which we wish to break our CSS into as many separate files as we wish, since this makes developing and debugging much easier.

Performance isn't a concern, as we do compress all these files into a single package prior to deployment.

The problem is on the development side. How can we work with more than 32 stylesheets if IE 7 has an upper limit of 32?

Is there any means of hacking around this?

I'm trying to come up with solutions, but it seems that even if I loaded the stylesheets via Ajax, I'd still be writing out tags, which would still count towards the 32-stylesheet limit.

Is this the case? Am I stuck with the 32-file limit or is there a way around it?

NOTE: I'm asking for a client-side solution to this. Obviousy a server-side solution isn't necessary as we already have a compression system in place. I just don't want to have to do a re-compress every time I make one little CSS change that I want to test.

4

6 回答 6

5

我将把它添加为一个单独的答案,只是为了看看它得到了多少赞成票和反对票:

不支持IE7。

编辑:为避免混淆:我并没有认真建议这是一个真正的解决方案。请不要着火!

于 2010-10-26T23:16:50.757 回答
1

Have you tried @import?

于 2010-10-26T23:12:34.763 回答
1

Create CSS files on the server side and merge all files that are needed for this certain page.

If you are using Apache or Lighttp consider using mod_concat

于 2010-10-26T23:52:15.620 回答
1

使用 Javascript 使用 cssText 属性将样式表写入现有样式块,如下所示:

document.styleSheets[0].cssText += ourCss;

更多信息在这里:

http://bushrobot.blogspot.co.uk/2012/06/getting-around-31-stylesheet-limit-in.html

于 2012-07-21T20:13:22.983 回答
0

在我的上一家公司,我们通过将所有 CSS 混合到一个大文档中并在引用该一次性文档的网页中插入一个 URL 来解决这个问题。这一切都是即时完成的,就在将页面返回给客户端之前(我们在幕后进行了一堆生成动态 CSS 的工作)。

根据您的设置,您也许可以让您的 Web 服务器执行类似的操作,否则听起来您只能使用 32 个文件。

或者你不能支持 IE7 ;)

于 2010-10-26T23:15:54.097 回答
-1

不是真正的答案,但我记得在使用 Drupal 6 (CMS) 时,有一个选项可以在请求页面时聚合样式表。也许您可以以编程方式做类似的事情。

于 2010-10-26T23:17:08.510 回答