简体   繁体   English

合并带有导入的CSS文件

[英]Merging CSS files with an import

I have about 40 'themes' that have each been copied and pasted from a 'default' theme and been modified uniquely. 我大约有40个“主题”,每个主题都是从“默认”主题复制并粘贴的,并且经过了独特的修改。 As time has gone on each of these themes has taken a shape of its own, some more, some less. 随着时间的流逝,这些主题已逐渐形成自己的形状,有些或多或少。

I need to be able to do an @import url(default.css); 我需要能够做一个@import url(default.css); so that when I make changes to the default I do not need to cascade it down to all the themes. 因此,当我更改默认值时,不需要将其级联到所有主题。

Each theme and the default is about 2000 lines. 每个主题和默认值约为2000行。 I have tried to use a css optimizer but I couldn't get it to work. 我尝试使用CSS优化器,但是无法正常工作。 (Perhaps I'm doing something wrong?) Right now I'm just using diff to do all the changes line by line and it painstaking and will take me weeks upon weeks. (也许我做错了什么?)现在,我只是使用diff逐行进行所有更改,这很费力,并且需要数周的时间。

How do I do this quickly? 我该如何快速进行? There has got to be a way. 必须有一种方法。

maybe you need to go about this problem with with something like this: seperate the css files. 也许您需要使用以下方法解决此问题:分离css文件。

create a base file. 创建一个基本文件。

that way things that are general to all themes will be at the base. 这样,所有主题通用的事物将成为基础。 and stuff that are indevidual will have to be put inside each of the 40 files avcorse. 并且独立的内容必须放入avcorse的40个文件中的每个文件中。

Maybe a de -optimizer would do some good, but I don't know of any. 取消优化器可能会有所帮助,但我一无所知。 It would allow to have one and only one instruction per rule, like: 每个规则只允许有一条指令,例如:

selector1,selector2 {
  instruction1;
  instruction2;
}

becoming 变得

selector1 { instruction1; }
selector2 { instruction1; }
selector1 { instruction2; }
selector2 { instruction2; }

That would allow you to use diff way faster and finally to combine these with an optimizer ... 这将使您能够更快地使用diff方式,最后将它们与优化器结合起来...

Other than that: 除此之外:

  • I'd try PSPad (shareware, not free for commercial use) to get one-line CSS rules (menu HTML, format CSS inline ). 我会尝试使用PSPad(共享软件,并非免费用于商业用途)来获取单行CSS规则(菜单HTML,格式化CSS inline )。 This will sort of associate instructions to their rule selector(s) when you use diff. 当您使用diff时,这会将排序指令与其规则选择器相关联。
  • Then use softwares like Diffuse to compare a set of files (GPL) or DiffMerge (free for 30 days) or KDiff3 (GPL) to compare files 3 per 3 然后使用Diffuse之类的软件来比较一文件(GPL)或DiffMerge (30天免费)或KDiff3 (GPL)来比较每3个文件中的3个
  • and get a default stylesheet and 40 shorter stylesheets 并获得默认样式表和40个较短的样式表

But you'll still have to check each template after having modified your default one: you can't know for sure, now or later, how each template overrid or not instructions from default stylesheet. 但是在修改默认模板后,您仍然必须检查每个模板:您不确定现在或以后,每个模板如何覆盖或不覆盖默认样式表中的指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM