我的网站上有多个主题,用户只需单击 JavaScript 链接即可在多个主题之间切换。 我有 5 个 CSS 文件来处理所有主题的布局。
1 用于结构,3 用于不同主题的颜色等,1 用于其他一些东西。
我的 css 文件名是这样的..
main.css、红色.css、绿色.css、黑色.css、其他.css
红色、绿色和黑色的 css 文件被定义为备用样式表
。
我已经安装了YSLOW! 并得到“此页面有 5 个外部样式表。尝试将它们合并为一个。”
我只是想知道是否可以将其中大部分合并为更少数量的 CSS 文件。 我知道我们可以定义
`
@media screen
{
//screen
}
@media print
{
//print
}
`
单个 CSS 文件中的部分。 可以对多个 CSS 文件执行类似的操作吗?
感谢您的帮助。
I have multiple themes on my website and users can just switch between multiple themes by clicking on a javascript link. I have 5 CSS files to handle the layout of all of the themes.
1 is for structure, 3 are for colors etc for different themes, and 1 common for some other stuff.
my css filenames read like this ..
main.css, red.css, green.css, black.css, others.css
With red, green and black css files are defined as alternate stylesheet
s.
I have installed YSLOW! and get "This page has 5 external stylesheets. Try combining them into one."
I was just wondering if it is possible to combine most of them into a fewer numbers of CSS files. I know that we can define
`
@media screen
{
//screen
}
@media print
{
//print
}
`
sections in a single CSS file. Can something like this be done for multiple CSS files as well?
Thanks for your help.
发布评论
评论(4)
你的 main 和 other 可以组合起来,那么你可以在必要时不使用 javascript 加载它们,而不是附加其他三个吗?
像这样的事情:
Your main and other can be combined, then rather than attaching the other three, can you not jsut load them with javascript when necessary?
Something like this:
组合两个常见的样式表,并忽略替代样式表的 YSlow。 YSlow是一个工具,而不是法律的执行者。
Combine the two common stylesheets, and ignore YSlow for the alternative ones. YSlow is a tool, not the enforcer of the law.
您可以不交换样式表,而是将样式表合并为一个,并使用主体上的类更改颜色。 用一个例子更容易描述这一点:
假设您当前有
red.css
green.css
,并且您使用 JavaScript 在它们之间进行交换。
为什么不将其更改为:
colors.css
并用 JavaScript 交换主体上的类。 那么你就只有一个 CSS 文件,而且 JavaScript 也简单得多。
You could, instead of swapping stylesheets, combine the stylesheets into one and change the colours with a class on the body instead. This is easier to describe with an example:
Say you currently have
red.css
green.css
and you swap between them with JavaScript.
Why not change that to:
colors.css
and swap the class on the body with JavaScript. Then you only have one CSS file and the JavaScript is much simpler too.
您可以向 body 标记添加一个 class 属性,并通过
JavaScript
更改它。 然后您可以将所有样式表合并为一个。编写样式表的一个有趣的工具是 HSS 它可以帮助您创建嵌套结构。
You could add a class attribute to the body tag and change this by
JavaScript
. Then you could combine all stylesheet into one.An interessting tool for writing stylesheets is HSS it helps you to create nested structures.