如何包含所有保存在目录中的css? [英] How to include all css kept in a directory?

查看:77
本文介绍了如何包含所有保存在目录中的css?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在html中一次包含多个css?或者更确切地说,是否有可能将所有放置在目录中的css放在一个目录中?

目前我们所做的是: -

Is it possible to include multiple css at once in html? Or to be precise, is it possible to include all css placed in a directory, in one go?
like at present what we do is:-

<link type="text/css" rel="stylesheet" href="./tabs_css/navigation.css">

我需要这样的东西: -

i need something like:-

<link type="text/css" rel="stylesheet" href="./tabs_css/*.css">

可能吗?或者是否有其他选择?

Is it possible? or is there any alternative of this?

推荐答案

您可以创建一个包含在每个页面中的主样式表,并且在该css您可以使用 @import 来包含其他文件。

You could create a master stylesheet that you include in every page, and within that css file you can use @import to include the others.

这并不能解决必须手动包含每个单独的css文件,但至少将其封装在主样式表中,因此不必重复每个html文件中的所有引用。如果你添加额外的CSS文件,你只需要在master CSS中添加一个引用,所有的页面都可以访问它。

This doesn't solve the problem of having to manually include each individual css file, but at least it encapsulates it within the master stylesheet so you don't have to repeat all of the references in every html file. If you add additional css files you will only need to add a reference in the master css and all pages will get access to it.

示例HTML CSS参考:

Example HTML CSS Reference:

<link href="master.css" type="text/css" />

示例Master CSS(master.css):

Example Master CSS (master.css):

@import url(style1.css);
@import url(style2.css);
@import url(style3.css);

了解更多关于何时使用@import及其与旧版浏览器的兼容性。

Read more about when to use @import and it's compatibility with older browsers.

这篇关于如何包含所有保存在目录中的css?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆