在同一个html文件中使用两个css文件 [英] Using two css files in the same html file

查看:554
本文介绍了在同一个html文件中使用两个css文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在同一个HTML文件中使用具有相同名称的选择器等的2个CSS类?

Is it possible to use 2 CSS classes that have the same name for the selectors, etc. in the same HTML file? If so, how do you differentiate between the two when styling elements?

推荐答案

是的,这是可能的,只需要包含两个css文件文档的HEAD部分。第一个中设置的任何样式都将在第二个样式中被覆盖,所以说你有这样的样子:

第一个文件:

Yes this is possible, simply include two css files in the HEAD section of the document. Any styles set in the first will be overwritten in the second, so say you have this:
First file:

 #something{
  background-color: #F00;
  color: #FFF;
 }

然后在第二个文件中:

 #something{
  background-color: #000;
 }

然后#something的背景颜色将在第二个文件中覆盖为黑色但颜色将保持不变,因为第二个文件不说任何东西。

Then the background color for #something will be overwritten in the second file to black but the color will stay the same since the second file doesn't say anything about it.

这篇关于在同一个html文件中使用两个css文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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