是否有可能有一个单一的HTML文件的多个CSS文件(模块化样式表) [英] Is it possible to have multiple css files for a single html file (to modularise the style sheets)

查看:115
本文介绍了是否有可能有一个单一的HTML文件的多个CSS文件(模块化样式表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用多个样式表,以便可以设置页面的不同部分。这可能吗?如果是这样,是不是像添加链接到样式表一样简单,还是比这更复杂? 是的,它是可能的,并且也很简单,只需将每个样式添加到HTML文件中即可。但请记住,使用更多样式表并不是保持良好性能的最佳方式。

在呈现您的html时,您的浏览器只能下载一次2个并行文件。所以使用超过1个css文件会对你的性能产生负面影响。为避免这种情况,我建议在开发过程中使用更多的css文件,并使用Grunt或Gulp等工具将所有不同的css文件合并到一个文件中。


I want to be able to use several style sheets so that I can style different parts of a page. Is this possible? If so, is it as simple as adding links to the style sheets or is it more complex than that?

解决方案

Yes, it is possible and also as simple as you pointed it out, just by simply adding each style into your html file. But keep in mind, using more style sheets is not the best way in order to keep up a good performance.

While rendering your html, your browser is only able of downloading 2 parallel files at a time. So using more than 1 css file would have negative effects on your performance. To avoid that I would recommend using more css files during development and using some tools like Grunt or Gulp to put all of your different css files together into 1 file.

这篇关于是否有可能有一个单一的HTML文件的多个CSS文件(模块化样式表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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