如何包括所有css保存在目录? [英] How to include all css kept in a direcotry?

查看:101
本文介绍了如何包括所有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">

我需要类似: -

<link type="text/css" rel="stylesheet" href="./tabs_css/*.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文件,您只需在主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" />

示例主CSS(master.css):

Example Master CSS (master.css):

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

详细了解何时使用@import及其与旧版浏览器的兼容性

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

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