重写文件之间的css属性

重写文件之间的css属性,css,Css,我有两个CSS文件test1.CSS和test2.CSS,如下所示: test1.css body { background: blue; } body { font-weight: bold; } test2.css body { background: blue; } body { font-weight: bold; } 我在我的test.html中导入了两个CSS文件,使用: <link type="text/css" rel="stylesheet" href

我有两个CSS文件
test1.CSS
test2.CSS
,如下所示:

test1.css

body {
  background: blue;
}
body {
 font-weight: bold;
}
test2.css

body {
  background: blue;
}
body {
 font-weight: bold;
}
我在我的
test.html
中导入了两个CSS文件,使用:

<link type="text/css" rel="stylesheet" href=“test1.css" />
<link type="text/css" rel="stylesheet" href=“test2.css" />


我不想在我的
正文
中应用
背景
&其他CSS属性,我只想应用
字体重量

在test2.CSS文件中,您可以使用
正文
上的
all:initial
放弃所有CSS,除了unicode bidi和方向,来自test1.css for
body

body {
  all: initial;
  font-weight: bold;
}
阅读:

CSS all shorthand属性将除unicode bidi和direction之外的所有属性重置为其初始值或继承值


要么删除第一个样式表的链接,要么在第二个样式表中为body定义一个背景。我认为你应该为此添加类,而不是调用不同的css。如果你关心IE,除了最新的safari,你需要一种不同的方法:我也需要IE,请告诉我我应该做些什么来支持IE@user123尝试
all:inherit
@rahuldesai,正如JonP所说,“all”属性不支持IE,所以我相信all:inherit也不支持IE